18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * amcore.c -- Support for Sysam AMCORE open board 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * (C) Copyright 2016, Angelo Dureghello <angelo@sysam.it> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 78c2ecf20Sopenharmony_ci * License. See the file COPYING in the main directory of this archive 88c2ecf20Sopenharmony_ci * for more details. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/device.h> 128c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 138c2ecf20Sopenharmony_ci#include <linux/dm9000.h> 148c2ecf20Sopenharmony_ci#include <linux/irq.h> 158c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 168c2ecf20Sopenharmony_ci#include <linux/mtd/mtd.h> 178c2ecf20Sopenharmony_ci#include <linux/mtd/map.h> 188c2ecf20Sopenharmony_ci#include <linux/mtd/partitions.h> 198c2ecf20Sopenharmony_ci#include <linux/mtd/physmap.h> 208c2ecf20Sopenharmony_ci#include <linux/i2c.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <asm/coldfire.h> 238c2ecf20Sopenharmony_ci#include <asm/mcfsim.h> 248c2ecf20Sopenharmony_ci#include <asm/io.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_DM9000) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define DM9000_IRQ 25 298c2ecf20Sopenharmony_ci#define DM9000_ADDR 0x30000000 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* 328c2ecf20Sopenharmony_ci * DEVICES and related device RESOURCES 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_cistatic struct resource dm9000_resources[] = { 358c2ecf20Sopenharmony_ci /* physical address of the address register (CMD [A2] to 0)*/ 368c2ecf20Sopenharmony_ci [0] = { 378c2ecf20Sopenharmony_ci .start = DM9000_ADDR, 388c2ecf20Sopenharmony_ci .end = DM9000_ADDR, 398c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 408c2ecf20Sopenharmony_ci }, 418c2ecf20Sopenharmony_ci /* 428c2ecf20Sopenharmony_ci * physical address of the data register (CMD [A2] to 1), 438c2ecf20Sopenharmony_ci * driver wants a range >=4 to assume a 32bit data bus 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci [1] = { 468c2ecf20Sopenharmony_ci .start = DM9000_ADDR + 4, 478c2ecf20Sopenharmony_ci .end = DM9000_ADDR + 7, 488c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 498c2ecf20Sopenharmony_ci }, 508c2ecf20Sopenharmony_ci /* IRQ line the device's interrupt pin is connected to */ 518c2ecf20Sopenharmony_ci [2] = { 528c2ecf20Sopenharmony_ci .start = DM9000_IRQ, 538c2ecf20Sopenharmony_ci .end = DM9000_IRQ, 548c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 558c2ecf20Sopenharmony_ci }, 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic struct dm9000_plat_data dm9000_platdata = { 598c2ecf20Sopenharmony_ci .flags = DM9000_PLATF_32BITONLY, 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic struct platform_device dm9000_device = { 638c2ecf20Sopenharmony_ci .name = "dm9000", 648c2ecf20Sopenharmony_ci .id = 0, 658c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(dm9000_resources), 668c2ecf20Sopenharmony_ci .resource = dm9000_resources, 678c2ecf20Sopenharmony_ci .dev = { 688c2ecf20Sopenharmony_ci .platform_data = &dm9000_platdata, 698c2ecf20Sopenharmony_ci } 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci#endif 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic void __init dm9000_pre_init(void) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci /* Set the dm9000 interrupt to be auto-vectored */ 768c2ecf20Sopenharmony_ci mcf_autovector(DM9000_IRQ); 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * Partitioning of parallel NOR flash (39VF3201B) 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_cistatic struct mtd_partition amcore_partitions[] = { 838c2ecf20Sopenharmony_ci { 848c2ecf20Sopenharmony_ci .name = "U-Boot (128K)", 858c2ecf20Sopenharmony_ci .size = 0x20000, 868c2ecf20Sopenharmony_ci .offset = 0x0 878c2ecf20Sopenharmony_ci }, 888c2ecf20Sopenharmony_ci { 898c2ecf20Sopenharmony_ci .name = "Kernel+ROMfs (2994K)", 908c2ecf20Sopenharmony_ci .size = 0x2E0000, 918c2ecf20Sopenharmony_ci .offset = MTDPART_OFS_APPEND 928c2ecf20Sopenharmony_ci }, 938c2ecf20Sopenharmony_ci { 948c2ecf20Sopenharmony_ci .name = "Flash Free Space (1024K)", 958c2ecf20Sopenharmony_ci .size = MTDPART_SIZ_FULL, 968c2ecf20Sopenharmony_ci .offset = MTDPART_OFS_APPEND 978c2ecf20Sopenharmony_ci } 988c2ecf20Sopenharmony_ci}; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic struct physmap_flash_data flash_data = { 1018c2ecf20Sopenharmony_ci .parts = amcore_partitions, 1028c2ecf20Sopenharmony_ci .nr_parts = ARRAY_SIZE(amcore_partitions), 1038c2ecf20Sopenharmony_ci .width = 2, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic struct resource flash_resource = { 1078c2ecf20Sopenharmony_ci .start = 0xffc00000, 1088c2ecf20Sopenharmony_ci .end = 0xffffffff, 1098c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistatic struct platform_device flash_device = { 1138c2ecf20Sopenharmony_ci .name = "physmap-flash", 1148c2ecf20Sopenharmony_ci .id = -1, 1158c2ecf20Sopenharmony_ci .resource = &flash_resource, 1168c2ecf20Sopenharmony_ci .num_resources = 1, 1178c2ecf20Sopenharmony_ci .dev = { 1188c2ecf20Sopenharmony_ci .platform_data = &flash_data, 1198c2ecf20Sopenharmony_ci }, 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic struct platform_device rtc_device = { 1238c2ecf20Sopenharmony_ci .name = "rtc-ds1307", 1248c2ecf20Sopenharmony_ci .id = -1, 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic struct i2c_board_info amcore_i2c_info[] __initdata = { 1288c2ecf20Sopenharmony_ci { 1298c2ecf20Sopenharmony_ci I2C_BOARD_INFO("ds1338", 0x68), 1308c2ecf20Sopenharmony_ci }, 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic struct platform_device *amcore_devices[] __initdata = { 1348c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_DM9000) 1358c2ecf20Sopenharmony_ci &dm9000_device, 1368c2ecf20Sopenharmony_ci#endif 1378c2ecf20Sopenharmony_ci &flash_device, 1388c2ecf20Sopenharmony_ci &rtc_device, 1398c2ecf20Sopenharmony_ci}; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cistatic int __init init_amcore(void) 1428c2ecf20Sopenharmony_ci{ 1438c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_DM9000) 1448c2ecf20Sopenharmony_ci dm9000_pre_init(); 1458c2ecf20Sopenharmony_ci#endif 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci /* Add i2c RTC Dallas chip supprt */ 1488c2ecf20Sopenharmony_ci i2c_register_board_info(0, amcore_i2c_info, 1498c2ecf20Sopenharmony_ci ARRAY_SIZE(amcore_i2c_info)); 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci platform_add_devices(amcore_devices, ARRAY_SIZE(amcore_devices)); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci return 0; 1548c2ecf20Sopenharmony_ci} 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ciarch_initcall(init_amcore); 157