summaryrefslogtreecommitdiffstats
path: root/bsps/shared/dev/i2c/spi-flash-m25p40.c
blob: 60c29c301175ff534d39656743294ec863dd83a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * SPI driver for M25P40 like spi flash device.
 */

/*
 * Copyright (c) 2007 embedded brains GmbH. All rights reserved.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <rtems.h>
#include <rtems/libi2c.h>

#include <libchip/spi-flash-m25p40.h>
#include <rtems/libio.h>


static spi_memdrv_t spi_flash_m25p40_rw_drv_t = {
  {/* public fields */
    .ops =         &spi_memdrv_rw_ops, /* operations of general memdrv */
    .size =        sizeof (spi_flash_m25p40_rw_drv_t),
  },
  { /* our private fields */
    .baudrate =             2000000,
    .erase_before_program = true,
    .empty_state =          0xff,
    .page_size =            256,     /* programming page size in bytes */
    .sector_size =          0x10000, /* 64K - erase sector size in bytes */
    .mem_size =             0x80000, /* 512K - total capacity in bytes */
  }
};

rtems_libi2c_drv_t *spi_flash_m25p40_rw_driver_descriptor =
&spi_flash_m25p40_rw_drv_t.libi2c_drv_entry;

static spi_memdrv_t spi_flash_m25p40_ro_drv_t = {
  {/* public fields */
    .ops =         &spi_memdrv_ro_ops, /* operations of general memdrv */
    .size =        sizeof (spi_flash_m25p40_ro_drv_t),
  },
  { /* our private fields */
    .baudrate =             2000000,
    .erase_before_program = true,
    .empty_state =          0xff,
    .page_size =            256,    /* programming page size in bytes */
    .sector_size =          0x10000, /* 64K erase sector size in bytes */
    .mem_size =             0x80000, /* 512K total capacity in bytes */
  }
};

rtems_libi2c_drv_t *spi_flash_m25p40_ro_driver_descriptor =
&spi_flash_m25p40_ro_drv_t.libi2c_drv_entry;