Commit ff0960f9a018952cbaab59c0d87b6e0338c8f04c

Authored by Simon Glass
1 parent 0043b1faa7

sf: Tidy up public and private header files

Since spi_flash.h is supposed to be the public API for SPI flash, move
private things to sf_internal.h. Also tidy up a few comment nits.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>

Showing 9 changed files with 73 additions and 60 deletions Side-by-side Diff

board/buffalo/lsxl/lsxl.c
... ... @@ -13,11 +13,12 @@
13 13 #include <malloc.h>
14 14 #include <netdev.h>
15 15 #include <miiphy.h>
  16 +#include <spi.h>
  17 +#include <spi_flash.h>
16 18 #include <asm/arch/kirkwood.h>
17 19 #include <asm/arch/cpu.h>
18 20 #include <asm/arch/mpp.h>
19 21 #include <asm/arch/gpio.h>
20   -#include <spi_flash.h>
21 22  
22 23 #include "lsxl.h"
23 24  
board/renesas/sh7752evb/sh7752evb.c
... ... @@ -9,6 +9,7 @@
9 9 #include <asm/processor.h>
10 10 #include <asm/io.h>
11 11 #include <asm/mmc.h>
  12 +#include <spi.h>
12 13 #include <spi_flash.h>
13 14  
14 15 int checkboard(void)
board/renesas/sh7753evb/sh7753evb.c
... ... @@ -9,6 +9,7 @@
9 9 #include <asm/processor.h>
10 10 #include <asm/io.h>
11 11 #include <asm/mmc.h>
  12 +#include <spi.h>
12 13 #include <spi_flash.h>
13 14  
14 15 int checkboard(void)
board/renesas/sh7757lcr/sh7757lcr.c
... ... @@ -9,6 +9,7 @@
9 9 #include <asm/processor.h>
10 10 #include <asm/io.h>
11 11 #include <asm/mmc.h>
  12 +#include <spi.h>
12 13 #include <spi_flash.h>
13 14  
14 15 int checkboard(void)
... ... @@ -9,6 +9,7 @@
9 9 #include <common.h>
10 10 #include <div64.h>
11 11 #include <malloc.h>
  12 +#include <spi.h>
12 13 #include <spi_flash.h>
13 14  
14 15 #include <asm/io.h>
drivers/mtd/spi/ramtron.c
... ... @@ -35,6 +35,7 @@
35 35  
36 36 #include <common.h>
37 37 #include <malloc.h>
  38 +#include <spi.h>
38 39 #include <spi_flash.h>
39 40 #include "sf_internal.h"
40 41  
drivers/mtd/spi/sf_internal.h
... ... @@ -10,6 +10,36 @@
10 10 #ifndef _SF_INTERNAL_H_
11 11 #define _SF_INTERNAL_H_
12 12  
  13 +#include <linux/types.h>
  14 +#include <linux/compiler.h>
  15 +
  16 +/* Dual SPI flash memories - see SPI_COMM_DUAL_... */
  17 +enum spi_dual_flash {
  18 + SF_SINGLE_FLASH = 0,
  19 + SF_DUAL_STACKED_FLASH = 1 << 0,
  20 + SF_DUAL_PARALLEL_FLASH = 1 << 1,
  21 +};
  22 +
  23 +/* Enum list - Full read commands */
  24 +enum spi_read_cmds {
  25 + ARRAY_SLOW = 1 << 0,
  26 + DUAL_OUTPUT_FAST = 1 << 1,
  27 + DUAL_IO_FAST = 1 << 2,
  28 + QUAD_OUTPUT_FAST = 1 << 3,
  29 + QUAD_IO_FAST = 1 << 4,
  30 +};
  31 +
  32 +#define RD_EXTN (ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST)
  33 +#define RD_FULL (RD_EXTN | QUAD_OUTPUT_FAST | QUAD_IO_FAST)
  34 +
  35 +/* sf param flags */
  36 +enum {
  37 + SECT_4K = 1 << 0,
  38 + SECT_32K = 1 << 1,
  39 + E_FSR = 1 << 2,
  40 + WR_QPP = 1 << 3,
  41 +};
  42 +
13 43 #define SPI_FLASH_3B_ADDR_LEN 3
14 44 #define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)
15 45 #define SPI_FLASH_16MB_BOUN 0x1000000
16 46  
... ... @@ -30,12 +60,12 @@
30 60 #define CMD_WRITE_STATUS 0x01
31 61 #define CMD_PAGE_PROGRAM 0x02
32 62 #define CMD_WRITE_DISABLE 0x04
33   -#define CMD_READ_STATUS 0x05
  63 +#define CMD_READ_STATUS 0x05
34 64 #define CMD_QUAD_PAGE_PROGRAM 0x32
35 65 #define CMD_READ_STATUS1 0x35
36 66 #define CMD_WRITE_ENABLE 0x06
37   -#define CMD_READ_CONFIG 0x35
38   -#define CMD_FLAG_STATUS 0x70
  67 +#define CMD_READ_CONFIG 0x35
  68 +#define CMD_FLAG_STATUS 0x70
39 69  
40 70 /* Read commands */
41 71 #define CMD_READ_ARRAY_SLOW 0x03
... ... @@ -57,7 +87,7 @@
57 87 /* Common status */
58 88 #define STATUS_WIP (1 << 0)
59 89 #define STATUS_QEB_WINSPAN (1 << 1)
60   -#define STATUS_QEB_MXIC (1 << 6)
  90 +#define STATUS_QEB_MXIC (1 << 6)
61 91 #define STATUS_PEC (1 << 7)
62 92  
63 93 #ifdef CONFIG_SYS_SPI_ST_ENABLE_WP_PIN
64 94  
65 95  
66 96  
... ... @@ -66,18 +96,41 @@
66 96  
67 97 /* Flash timeout values */
68 98 #define SPI_FLASH_PROG_TIMEOUT (2 * CONFIG_SYS_HZ)
69   -#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONFIG_SYS_HZ)
  99 +#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONFIG_SYS_HZ)
70 100 #define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CONFIG_SYS_HZ)
71 101  
72 102 /* SST specific */
73 103 #ifdef CONFIG_SPI_FLASH_SST
74   -# define SST_WP 0x01 /* Supports AAI word program */
  104 +# define SST_WP 0x01 /* Supports AAI word program */
75 105 # define CMD_SST_BP 0x02 /* Byte Program */
76   -# define CMD_SST_AAI_WP 0xAD /* Auto Address Incr Word Program */
  106 +# define CMD_SST_AAI_WP 0xAD /* Auto Address Incr Word Program */
77 107  
78 108 int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
79 109 const void *buf);
80 110 #endif
  111 +
  112 +/**
  113 + * struct spi_flash_params - SPI/QSPI flash device params structure
  114 + *
  115 + * @name: Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
  116 + * @jedec: Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
  117 + * @ext_jedec: Device ext_jedec ID
  118 + * @sector_size: Sector size of this device
  119 + * @nr_sectors: No.of sectors on this device
  120 + * @e_rd_cmd: Enum list for read commands
  121 + * @flags: Important param, for flash specific behaviour
  122 + */
  123 +struct spi_flash_params {
  124 + const char *name;
  125 + u32 jedec;
  126 + u16 ext_jedec;
  127 + u32 sector_size;
  128 + u32 nr_sectors;
  129 + u8 e_rd_cmd;
  130 + u16 flags;
  131 +};
  132 +
  133 +extern const struct spi_flash_params spi_flash_params_table[];
81 134  
82 135 /* Send a single-byte command to the device and read the response */
83 136 int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len);
drivers/mtd/spi/spi_spl_load.c
... ... @@ -10,6 +10,7 @@
10 10 */
11 11  
12 12 #include <common.h>
  13 +#include <spi.h>
13 14 #include <spi_flash.h>
14 15 #include <spl.h>
15 16  
... ... @@ -15,9 +15,7 @@
15 15 #ifndef _SPI_FLASH_H_
16 16 #define _SPI_FLASH_H_
17 17  
18   -#include <spi.h>
19 18 #include <linux/types.h>
20   -#include <linux/compiler.h>
21 19  
22 20 #ifndef CONFIG_SF_DEFAULT_SPEED
23 21 # define CONFIG_SF_DEFAULT_SPEED 1000000
24 22  
25 23  
26 24  
27 25  
... ... @@ -32,64 +30,19 @@
32 30 # define CONFIG_SF_DEFAULT_BUS 0
33 31 #endif
34 32  
35   -/* sf param flags */
36   -#define SECT_4K 1 << 1
37   -#define SECT_32K 1 << 2
38   -#define E_FSR 1 << 3
39   -#define WR_QPP 1 << 4
  33 +struct spi_slave;
40 34  
41   -/* Enum list - Full read commands */
42   -enum spi_read_cmds {
43   - ARRAY_SLOW = 1 << 0,
44   - DUAL_OUTPUT_FAST = 1 << 1,
45   - DUAL_IO_FAST = 1 << 2,
46   - QUAD_OUTPUT_FAST = 1 << 3,
47   - QUAD_IO_FAST = 1 << 4,
48   -};
49   -#define RD_EXTN ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST
50   -#define RD_FULL RD_EXTN | QUAD_OUTPUT_FAST | QUAD_IO_FAST
51   -
52   -/* Dual SPI flash memories */
53   -enum spi_dual_flash {
54   - SF_SINGLE_FLASH = 0,
55   - SF_DUAL_STACKED_FLASH = 1 << 0,
56   - SF_DUAL_PARALLEL_FLASH = 1 << 1,
57   -};
58   -
59 35 /**
60   - * struct spi_flash_params - SPI/QSPI flash device params structure
61   - *
62   - * @name: Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
63   - * @jedec: Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
64   - * @ext_jedec: Device ext_jedec ID
65   - * @sector_size: Sector size of this device
66   - * @nr_sectors: No.of sectors on this device
67   - * @e_rd_cmd: Enum list for read commands
68   - * @flags: Important param, for flash specific behaviour
69   - */
70   -struct spi_flash_params {
71   - const char *name;
72   - u32 jedec;
73   - u16 ext_jedec;
74   - u32 sector_size;
75   - u32 nr_sectors;
76   - u8 e_rd_cmd;
77   - u16 flags;
78   -};
79   -
80   -extern const struct spi_flash_params spi_flash_params_table[];
81   -
82   -/**
83 36 * struct spi_flash - SPI flash structure
84 37 *
85 38 * @spi: SPI slave
86 39 * @name: Name of SPI flash
87   - * @dual_flash: Indicates dual flash memories - dual stacked, parallel
  40 + * @dual_flash: Indicates dual flash memories - dual stacked, parallel
88 41 * @shift: Flash shift useful in dual parallel
89 42 * @size: Total flash size
90 43 * @page_size: Write (page) size
91 44 * @sector_size: Sector size
92   - * @erase_size: Erase size
  45 + * @erase_size: Erase size
93 46 * @bank_read_cmd: Bank read cmd
94 47 * @bank_write_cmd: Bank write cmd
95 48 * @bank_curr: Current flash bank
... ... @@ -97,8 +50,8 @@
97 50 * @erase_cmd: Erase cmd 4K, 32K, 64K
98 51 * @read_cmd: Read cmd - Array Fast, Extn read and quad read.
99 52 * @write_cmd: Write cmd - page and quad program.
100   - * @dummy_byte: Dummy cycles for read operation.
101   - * @memory_map: Address of read-only SPI flash access
  53 + * @dummy_byte: Dummy cycles for read operation.
  54 + * @memory_map: Address of read-only SPI flash access
102 55 * @read: Flash read ops: Read len bytes at offset into buf
103 56 * Supported cmds: Fast Array Read
104 57 * @write: Flash write ops: Write len bytes from buf into offset