diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2008-08-19 09:55:14 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-10-11 11:18:44 -0400 |
commit | d75a40e90e9eb08c2159e719a90a7922dab231d3 (patch) | |
tree | 5218a3fd78998fb47247ccbc35115a1cc42a265d /arch | |
parent | e6332374770ae5aa370af5792115261edbad05c1 (diff) |
MIPS: TXx9: Make spi_eeprom.c more generic
Helper routines in txx9/rbtx4938/spi_eeprom.c is not TX4938 specific.
Move it to txx9/generic/ directory and make it works with SPI bus
number other than 0.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
create mode 100644 arch/mips/txx9/generic/spi_eeprom.c
delete mode 100644 arch/mips/txx9/rbtx4938/spi_eeprom.c
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/txx9/generic/Makefile | 1 | ||||
-rw-r--r-- | arch/mips/txx9/generic/spi_eeprom.c (renamed from arch/mips/txx9/rbtx4938/spi_eeprom.c) | 28 | ||||
-rw-r--r-- | arch/mips/txx9/rbtx4938/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/txx9/rbtx4938/setup.c | 11 |
4 files changed, 24 insertions, 18 deletions
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile index 9bb34af26b73..986852cc774c 100644 --- a/arch/mips/txx9/generic/Makefile +++ b/arch/mips/txx9/generic/Makefile | |||
@@ -8,5 +8,6 @@ obj-$(CONFIG_SOC_TX3927) += setup_tx3927.o irq_tx3927.o | |||
8 | obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o setup_tx4927.o irq_tx4927.o | 8 | obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o setup_tx4927.o irq_tx4927.o |
9 | obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o | 9 | obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o |
10 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o | 10 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o |
11 | obj-$(CONFIG_SPI) += spi_eeprom.o | ||
11 | 12 | ||
12 | EXTRA_CFLAGS += -Werror | 13 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/mips/txx9/rbtx4938/spi_eeprom.c b/arch/mips/txx9/generic/spi_eeprom.c index a7ea8b041c1d..75c347238f47 100644 --- a/arch/mips/txx9/rbtx4938/spi_eeprom.c +++ b/arch/mips/txx9/generic/spi_eeprom.c | |||
@@ -18,29 +18,31 @@ | |||
18 | #define AT250X0_PAGE_SIZE 8 | 18 | #define AT250X0_PAGE_SIZE 8 |
19 | 19 | ||
20 | /* register board information for at25 driver */ | 20 | /* register board information for at25 driver */ |
21 | int __init spi_eeprom_register(int chipid) | 21 | int __init spi_eeprom_register(int busid, int chipid, int size) |
22 | { | 22 | { |
23 | static struct spi_eeprom eeprom = { | ||
24 | .name = "at250x0", | ||
25 | .byte_len = 128, | ||
26 | .page_size = AT250X0_PAGE_SIZE, | ||
27 | .flags = EE_ADDR1, | ||
28 | }; | ||
29 | struct spi_board_info info = { | 23 | struct spi_board_info info = { |
30 | .modalias = "at25", | 24 | .modalias = "at25", |
31 | .max_speed_hz = 1500000, /* 1.5Mbps */ | 25 | .max_speed_hz = 1500000, /* 1.5Mbps */ |
32 | .bus_num = 0, | 26 | .bus_num = busid, |
33 | .chip_select = chipid, | 27 | .chip_select = chipid, |
34 | .platform_data = &eeprom, | ||
35 | /* Mode 0: High-Active, Sample-Then-Shift */ | 28 | /* Mode 0: High-Active, Sample-Then-Shift */ |
36 | }; | 29 | }; |
37 | 30 | struct spi_eeprom *eeprom; | |
31 | eeprom = kzalloc(sizeof(*eeprom), GFP_KERNEL); | ||
32 | if (!eeprom) | ||
33 | return -ENOMEM; | ||
34 | strcpy(eeprom->name, "at250x0"); | ||
35 | eeprom->byte_len = size; | ||
36 | eeprom->page_size = AT250X0_PAGE_SIZE; | ||
37 | eeprom->flags = EE_ADDR1; | ||
38 | info.platform_data = eeprom; | ||
38 | return spi_register_board_info(&info, 1); | 39 | return spi_register_board_info(&info, 1); |
39 | } | 40 | } |
40 | 41 | ||
41 | /* simple temporary spi driver to provide early access to seeprom. */ | 42 | /* simple temporary spi driver to provide early access to seeprom. */ |
42 | 43 | ||
43 | static struct read_param { | 44 | static struct read_param { |
45 | int busid; | ||
44 | int chipid; | 46 | int chipid; |
45 | int address; | 47 | int address; |
46 | unsigned char *buf; | 48 | unsigned char *buf; |
@@ -57,7 +59,8 @@ static int __init early_seeprom_probe(struct spi_device *spi) | |||
57 | 59 | ||
58 | dev_info(&spi->dev, "spiclk %u KHz.\n", | 60 | dev_info(&spi->dev, "spiclk %u KHz.\n", |
59 | (spi->max_speed_hz + 500) / 1000); | 61 | (spi->max_speed_hz + 500) / 1000); |
60 | if (read_param->chipid != spi->chip_select) | 62 | if (read_param->busid != spi->master->bus_num || |
63 | read_param->chipid != spi->chip_select) | ||
61 | return -ENODEV; | 64 | return -ENODEV; |
62 | while (len > 0) { | 65 | while (len > 0) { |
63 | /* spi_write_then_read can only work with small chunk */ | 66 | /* spi_write_then_read can only work with small chunk */ |
@@ -80,11 +83,12 @@ static struct spi_driver early_seeprom_driver __initdata = { | |||
80 | .probe = early_seeprom_probe, | 83 | .probe = early_seeprom_probe, |
81 | }; | 84 | }; |
82 | 85 | ||
83 | int __init spi_eeprom_read(int chipid, int address, | 86 | int __init spi_eeprom_read(int busid, int chipid, int address, |
84 | unsigned char *buf, int len) | 87 | unsigned char *buf, int len) |
85 | { | 88 | { |
86 | int ret; | 89 | int ret; |
87 | struct read_param param = { | 90 | struct read_param param = { |
91 | .busid = busid, | ||
88 | .chipid = chipid, | 92 | .chipid = chipid, |
89 | .address = address, | 93 | .address = address, |
90 | .buf = buf, | 94 | .buf = buf, |
diff --git a/arch/mips/txx9/rbtx4938/Makefile b/arch/mips/txx9/rbtx4938/Makefile index 9dcc52ae5b9d..f3e1f597b4f1 100644 --- a/arch/mips/txx9/rbtx4938/Makefile +++ b/arch/mips/txx9/rbtx4938/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | obj-y += prom.o setup.o irq.o spi_eeprom.o | 1 | obj-y += prom.o setup.o irq.o |
2 | 2 | ||
3 | EXTRA_CFLAGS += -Werror | 3 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c index 7aba92a12399..ec6e81258f73 100644 --- a/arch/mips/txx9/rbtx4938/setup.c +++ b/arch/mips/txx9/rbtx4938/setup.c | |||
@@ -111,6 +111,7 @@ static void __init rbtx4938_pci_setup(void) | |||
111 | #define SEEPROM2_CS 0 /* IOC */ | 111 | #define SEEPROM2_CS 0 /* IOC */ |
112 | #define SEEPROM3_CS 1 /* IOC */ | 112 | #define SEEPROM3_CS 1 /* IOC */ |
113 | #define SRTC_CS 2 /* IOC */ | 113 | #define SRTC_CS 2 /* IOC */ |
114 | #define SPI_BUSNO 0 | ||
114 | 115 | ||
115 | static int __init rbtx4938_ethaddr_init(void) | 116 | static int __init rbtx4938_ethaddr_init(void) |
116 | { | 117 | { |
@@ -120,7 +121,7 @@ static int __init rbtx4938_ethaddr_init(void) | |||
120 | int i; | 121 | int i; |
121 | 122 | ||
122 | /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ | 123 | /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ |
123 | if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) { | 124 | if (spi_eeprom_read(SPI_BUSNO, SEEPROM1_CS, 0, dat, sizeof(dat))) { |
124 | printk(KERN_ERR "seeprom: read error.\n"); | 125 | printk(KERN_ERR "seeprom: read error.\n"); |
125 | return -ENODEV; | 126 | return -ENODEV; |
126 | } else { | 127 | } else { |
@@ -287,9 +288,9 @@ static int __init rbtx4938_spi_init(void) | |||
287 | .mode = SPI_MODE_1 | SPI_CS_HIGH, | 288 | .mode = SPI_MODE_1 | SPI_CS_HIGH, |
288 | }; | 289 | }; |
289 | spi_register_board_info(&srtc_info, 1); | 290 | spi_register_board_info(&srtc_info, 1); |
290 | spi_eeprom_register(SEEPROM1_CS); | 291 | spi_eeprom_register(SPI_BUSNO, SEEPROM1_CS, 128); |
291 | spi_eeprom_register(16 + SEEPROM2_CS); | 292 | spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM2_CS, 128); |
292 | spi_eeprom_register(16 + SEEPROM3_CS); | 293 | spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM3_CS, 128); |
293 | gpio_request(16 + SRTC_CS, "rtc-rs5c348"); | 294 | gpio_request(16 + SRTC_CS, "rtc-rs5c348"); |
294 | gpio_direction_output(16 + SRTC_CS, 0); | 295 | gpio_direction_output(16 + SRTC_CS, 0); |
295 | gpio_request(SEEPROM1_CS, "seeprom1"); | 296 | gpio_request(SEEPROM1_CS, "seeprom1"); |
@@ -298,7 +299,7 @@ static int __init rbtx4938_spi_init(void) | |||
298 | gpio_direction_output(16 + SEEPROM2_CS, 1); | 299 | gpio_direction_output(16 + SEEPROM2_CS, 1); |
299 | gpio_request(16 + SEEPROM3_CS, "seeprom3"); | 300 | gpio_request(16 + SEEPROM3_CS, "seeprom3"); |
300 | gpio_direction_output(16 + SEEPROM3_CS, 1); | 301 | gpio_direction_output(16 + SEEPROM3_CS, 1); |
301 | tx4938_spi_init(0); | 302 | tx4938_spi_init(SPI_BUSNO); |
302 | return 0; | 303 | return 0; |
303 | } | 304 | } |
304 | 305 | ||