2 * File: arch/blackfin/mach-bf561/acvilon.c
3 * Based on: arch/blackfin/mach-bf561/ezkit.c
10 * Copyright 2004-2006 Analog Devices Inc.
11 * Copyright 2009 CJSC "NII STT"
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 * For more information about Acvilon BF561 SoM please
32 * go to http://www.niistt.ru/
36 #include <linux/device.h>
37 #include <linux/platform_device.h>
38 #include <linux/mtd/mtd.h>
39 #include <linux/mtd/partitions.h>
40 #include <linux/mtd/physmap.h>
41 #include <linux/mtd/nand.h>
42 #include <linux/mtd/plat-ram.h>
43 #include <linux/spi/spi.h>
44 #include <linux/spi/flash.h>
45 #include <linux/irq.h>
46 #include <linux/interrupt.h>
47 #include <linux/gpio.h>
48 #include <linux/jiffies.h>
49 #include <linux/i2c-pca-platform.h>
50 #include <linux/delay.h>
53 #include <asm/bfin5xx_spi.h>
54 #include <asm/portmux.h>
56 #include <asm/cacheflush.h>
57 #include <linux/i2c.h>
60 * Name the Board for the /proc/cpuinfo
62 const char bfin_board_name
[] = "Acvilon board";
64 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
65 #include <linux/usb/isp1760.h>
66 static struct resource bfin_isp1760_resources
[] = {
69 .end
= 0x20000000 + 0x000fffff,
70 .flags
= IORESOURCE_MEM
,
75 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
79 static struct isp1760_platform_data isp1760_priv
= {
85 .dack_polarity_high
= 0,
86 .dreq_polarity_high
= 0,
89 static struct platform_device bfin_isp1760_device
= {
90 .name
= "isp1760-hcd",
93 .platform_data
= &isp1760_priv
,
95 .num_resources
= ARRAY_SIZE(bfin_isp1760_resources
),
96 .resource
= bfin_isp1760_resources
,
100 static struct resource bfin_i2c_pca_resources
[] = {
102 .name
= "pca9564-regs",
104 .end
= 0x2C000000 + 16,
105 .flags
= IORESOURCE_MEM
| IORESOURCE_MEM_32BIT
,
110 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
114 struct i2c_pca9564_pf_platform_data pca9564_platform_data
= {
116 .i2c_clock_speed
= 330000,
120 /* PCA9564 I2C Bus driver */
121 static struct platform_device bfin_i2c_pca_device
= {
122 .name
= "i2c-pca-platform",
124 .num_resources
= ARRAY_SIZE(bfin_i2c_pca_resources
),
125 .resource
= bfin_i2c_pca_resources
,
127 .platform_data
= &pca9564_platform_data
,
131 /* I2C devices fitted. */
132 static struct i2c_board_info acvilon_i2c_devs
[] __initdata
= {
134 I2C_BOARD_INFO("ds1339", 0x68),
137 I2C_BOARD_INFO("tcn75", 0x49),
141 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
142 static struct platdata_mtd_ram mtd_ram_data
= {
143 .mapname
= "rootfs(RAM)",
147 static struct resource mtd_ram_resource
= {
150 .flags
= IORESOURCE_MEM
,
153 static struct platform_device mtd_ram_device
= {
157 .platform_data
= &mtd_ram_data
,
160 .resource
= &mtd_ram_resource
,
164 #if IS_ENABLED(CONFIG_SMSC911X)
165 #include <linux/smsc911x.h>
166 static struct resource smsc911x_resources
[] = {
168 .name
= "smsc911x-memory",
170 .end
= 0x28000000 + 0xFF,
171 .flags
= IORESOURCE_MEM
,
176 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
180 static struct smsc911x_platform_config smsc911x_config
= {
181 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
182 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
183 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
184 .phy_interface
= PHY_INTERFACE_MODE_MII
,
187 static struct platform_device smsc911x_device
= {
190 .num_resources
= ARRAY_SIZE(smsc911x_resources
),
191 .resource
= smsc911x_resources
,
193 .platform_data
= &smsc911x_config
,
198 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
199 #ifdef CONFIG_SERIAL_BFIN_UART0
200 static struct resource bfin_uart0_resources
[] = {
202 .start
= BFIN_UART_THR
,
203 .end
= BFIN_UART_GCTL
+ 2,
204 .flags
= IORESOURCE_MEM
,
207 .start
= IRQ_UART_TX
,
209 .flags
= IORESOURCE_IRQ
,
212 .start
= IRQ_UART_RX
,
214 .flags
= IORESOURCE_IRQ
,
217 .start
= IRQ_UART_ERROR
,
218 .end
= IRQ_UART_ERROR
,
219 .flags
= IORESOURCE_IRQ
,
224 .flags
= IORESOURCE_DMA
,
229 .flags
= IORESOURCE_DMA
,
233 static unsigned short bfin_uart0_peripherals
[] = {
234 P_UART0_TX
, P_UART0_RX
, 0
237 static struct platform_device bfin_uart0_device
= {
240 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
241 .resource
= bfin_uart0_resources
,
243 /* Passed to driver */
244 .platform_data
= &bfin_uart0_peripherals
,
250 #if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
252 static struct mtd_partition bfin_plat_nand_partitions
[] = {
254 .name
= "params(nand)",
255 .size
= 32 * 1024 * 1024,
258 .name
= "userfs(nand)",
259 .size
= MTDPART_SIZ_FULL
,
260 .offset
= MTDPART_OFS_APPEND
,
264 #define BFIN_NAND_PLAT_CLE 2
265 #define BFIN_NAND_PLAT_ALE 3
267 static void bfin_plat_nand_cmd_ctrl(struct mtd_info
*mtd
, int cmd
,
270 struct nand_chip
*this = mtd
->priv
;
272 if (cmd
== NAND_CMD_NONE
)
276 writeb(cmd
, this->IO_ADDR_W
+ (1 << BFIN_NAND_PLAT_CLE
));
278 writeb(cmd
, this->IO_ADDR_W
+ (1 << BFIN_NAND_PLAT_ALE
));
281 #define BFIN_NAND_PLAT_READY GPIO_PF10
282 static int bfin_plat_nand_dev_ready(struct mtd_info
*mtd
)
284 return gpio_get_value(BFIN_NAND_PLAT_READY
);
287 static struct platform_nand_data bfin_plat_nand_data
= {
291 .partitions
= bfin_plat_nand_partitions
,
292 .nr_partitions
= ARRAY_SIZE(bfin_plat_nand_partitions
),
295 .cmd_ctrl
= bfin_plat_nand_cmd_ctrl
,
296 .dev_ready
= bfin_plat_nand_dev_ready
,
300 #define MAX(x, y) (x > y ? x : y)
301 static struct resource bfin_plat_nand_resources
= {
303 .end
= 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE
, BFIN_NAND_PLAT_ALE
)),
304 .flags
= IORESOURCE_MEM
,
307 static struct platform_device bfin_async_nand_device
= {
311 .resource
= &bfin_plat_nand_resources
,
313 .platform_data
= &bfin_plat_nand_data
,
317 static void bfin_plat_nand_init(void)
319 gpio_request(BFIN_NAND_PLAT_READY
, "bfin_nand_plat");
322 static void bfin_plat_nand_init(void)
327 #if IS_ENABLED(CONFIG_MTD_DATAFLASH)
328 static struct mtd_partition bfin_spi_dataflash_partitions
[] = {
330 .name
= "bootloader",
333 .mask_flags
= MTD_CAP_ROM
},
337 .offset
= MTDPART_OFS_APPEND
,
340 .name
= "u-boot(params)",
342 .offset
= MTDPART_OFS_APPEND
,
347 .offset
= MTDPART_OFS_APPEND
,
352 .offset
= MTDPART_OFS_APPEND
,
356 .size
= MTDPART_SIZ_FULL
,
357 .offset
= MTDPART_OFS_APPEND
,
361 static struct flash_platform_data bfin_spi_dataflash_data
= {
362 .name
= "SPI Dataflash",
363 .parts
= bfin_spi_dataflash_partitions
,
364 .nr_parts
= ARRAY_SIZE(bfin_spi_dataflash_partitions
),
368 static struct bfin5xx_spi_chip data_flash_chip_info
= {
369 .enable_dma
= 0, /* use dma transfer with this chip */
373 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
375 static struct resource bfin_spi0_resource
[] = {
377 .start
= SPI0_REGBASE
,
378 .end
= SPI0_REGBASE
+ 0xFF,
379 .flags
= IORESOURCE_MEM
,
384 .flags
= IORESOURCE_DMA
,
389 .flags
= IORESOURCE_IRQ
,
393 /* SPI controller data */
394 static struct bfin5xx_spi_master bfin_spi0_info
= {
396 .enable_dma
= 1, /* master has the ability to do dma transfer */
397 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
400 static struct platform_device bfin_spi0_device
= {
402 .id
= 0, /* Bus number */
403 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
404 .resource
= bfin_spi0_resource
,
406 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
411 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
412 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
414 .modalias
= "spidev",
415 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
420 #if IS_ENABLED(CONFIG_MTD_DATAFLASH)
421 { /* DataFlash chip */
422 .modalias
= "mtd_dataflash",
423 .max_speed_hz
= 33250000, /* max spi clock (SCK) speed in HZ */
424 .bus_num
= 0, /* Framework bus number */
425 .chip_select
= 2, /* Framework chip select */
426 .platform_data
= &bfin_spi_dataflash_data
,
427 .controller_data
= &data_flash_chip_info
,
433 static struct resource bfin_gpios_resources
= {
435 /* .end = MAX_BLACKFIN_GPIOS - 1, */
437 .flags
= IORESOURCE_IRQ
,
440 static struct platform_device bfin_gpios_device
= {
441 .name
= "simple-gpio",
444 .resource
= &bfin_gpios_resources
,
447 static const unsigned int cclk_vlev_datasheet
[] = {
448 VRPAIR(VLEV_085
, 250000000),
449 VRPAIR(VLEV_090
, 300000000),
450 VRPAIR(VLEV_095
, 313000000),
451 VRPAIR(VLEV_100
, 350000000),
452 VRPAIR(VLEV_105
, 400000000),
453 VRPAIR(VLEV_110
, 444000000),
454 VRPAIR(VLEV_115
, 450000000),
455 VRPAIR(VLEV_120
, 475000000),
456 VRPAIR(VLEV_125
, 500000000),
457 VRPAIR(VLEV_130
, 600000000),
460 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
461 .tuple_tab
= cclk_vlev_datasheet
,
462 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
463 .vr_settling_time
= 25 /* us */ ,
466 static struct platform_device bfin_dpmc
= {
469 .platform_data
= &bfin_dmpc_vreg_data
,
473 static struct platform_device
*acvilon_devices
[] __initdata
= {
476 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
480 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
481 #ifdef CONFIG_SERIAL_BFIN_UART0
488 #if IS_ENABLED(CONFIG_SMSC911X)
492 &bfin_i2c_pca_device
,
494 #if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
495 &bfin_async_nand_device
,
498 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
504 static int __init
acvilon_init(void)
508 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
510 bfin_plat_nand_init();
512 platform_add_devices(acvilon_devices
, ARRAY_SIZE(acvilon_devices
));
516 i2c_register_board_info(0, acvilon_i2c_devs
,
517 ARRAY_SIZE(acvilon_i2c_devs
));
519 bfin_write_FIO0_FLAG_C(1 << 14);
521 bfin_write_FIO0_FLAG_S(1 << 14);
523 spi_register_board_info(bfin_spi_board_info
,
524 ARRAY_SIZE(bfin_spi_board_info
));
528 arch_initcall(acvilon_init
);
530 static struct platform_device
*acvilon_early_devices
[] __initdata
= {
531 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
532 #ifdef CONFIG_SERIAL_BFIN_UART0
538 void __init
native_machine_early_platform_add_devices(void)
540 printk(KERN_INFO
"register early platform devices\n");
541 early_platform_add_devices(acvilon_early_devices
,
542 ARRAY_SIZE(acvilon_early_devices
));