board-acs5k.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. * arch/arm/mach-ks8695/board-acs5k.c
  3. *
  4. * Brivo Systems LLC, ACS-5000 Master Board
  5. *
  6. * Copyright 2008 Simtec Electronics
  7. * Daniel Silverstone <dsilvers@simtec.co.uk>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c.h>
  19. #include <linux/i2c-algo-bit.h>
  20. #include <linux/i2c-gpio.h>
  21. #include <linux/i2c/pca953x.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/map.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <mach/devices.h>
  31. #include <mach/gpio.h>
  32. #include "generic.h"
  33. static struct i2c_gpio_platform_data acs5k_i2c_device_platdata = {
  34. .sda_pin = 4,
  35. .scl_pin = 5,
  36. .udelay = 10,
  37. };
  38. static struct platform_device acs5k_i2c_device = {
  39. .name = "i2c-gpio",
  40. .id = -1,
  41. .num_resources = 0,
  42. .resource = NULL,
  43. .dev = {
  44. .platform_data = &acs5k_i2c_device_platdata,
  45. },
  46. };
  47. static int acs5k_pca9555_setup(struct i2c_client *client,
  48. unsigned gpio_base, unsigned ngpio,
  49. void *context)
  50. {
  51. static int acs5k_gpio_value[] = {
  52. -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, -1, 0, 1, 0, -1, -1
  53. };
  54. int n;
  55. for (n = 0; n < ARRAY_SIZE(acs5k_gpio_value); ++n) {
  56. gpio_request(gpio_base + n, "ACS-5000 GPIO Expander");
  57. if (acs5k_gpio_value[n] < 0)
  58. gpio_direction_input(gpio_base + n);
  59. else
  60. gpio_direction_output(gpio_base + n,
  61. acs5k_gpio_value[n]);
  62. gpio_export(gpio_base + n, 0); /* Export, direction locked down */
  63. }
  64. return 0;
  65. }
  66. static struct pca953x_platform_data acs5k_i2c_pca9555_platdata = {
  67. .gpio_base = 16, /* Start directly after the CPU's GPIO */
  68. .invert = 0, /* Do not invert */
  69. .setup = acs5k_pca9555_setup,
  70. };
  71. static struct i2c_board_info acs5k_i2c_devs[] __initdata = {
  72. {
  73. I2C_BOARD_INFO("pcf8563", 0x51),
  74. },
  75. {
  76. I2C_BOARD_INFO("pca9555", 0x20),
  77. .platform_data = &acs5k_i2c_pca9555_platdata,
  78. },
  79. };
  80. static void __devinit acs5k_i2c_init(void)
  81. {
  82. /* The gpio interface */
  83. platform_device_register(&acs5k_i2c_device);
  84. /* I2C devices */
  85. i2c_register_board_info(0, acs5k_i2c_devs,
  86. ARRAY_SIZE(acs5k_i2c_devs));
  87. }
  88. static struct mtd_partition acs5k_nor_partitions[] = {
  89. [0] = {
  90. .name = "Boot Agent and config",
  91. .size = SZ_256K,
  92. .offset = 0,
  93. .mask_flags = MTD_WRITEABLE,
  94. },
  95. [1] = {
  96. .name = "Kernel",
  97. .size = SZ_1M,
  98. .offset = SZ_256K,
  99. },
  100. [2] = {
  101. .name = "SquashFS1",
  102. .size = SZ_2M,
  103. .offset = SZ_256K + SZ_1M,
  104. },
  105. [3] = {
  106. .name = "SquashFS2",
  107. .size = SZ_4M + SZ_2M,
  108. .offset = SZ_256K + SZ_1M + SZ_2M,
  109. },
  110. [4] = {
  111. .name = "Data",
  112. .size = SZ_16M + SZ_4M + SZ_2M + SZ_512K, /* 22.5 MB */
  113. .offset = SZ_256K + SZ_8M + SZ_1M,
  114. }
  115. };
  116. static struct physmap_flash_data acs5k_nor_pdata = {
  117. .width = 4,
  118. .nr_parts = ARRAY_SIZE(acs5k_nor_partitions),
  119. .parts = acs5k_nor_partitions,
  120. };
  121. static struct resource acs5k_nor_resource[] = {
  122. [0] = {
  123. .start = SZ_32M, /* We expect the bootloader to map
  124. * the flash here.
  125. */
  126. .end = SZ_32M + SZ_16M - 1,
  127. .flags = IORESOURCE_MEM,
  128. },
  129. [1] = {
  130. .start = SZ_32M + SZ_16M,
  131. .end = SZ_32M + SZ_32M - SZ_256K - 1,
  132. .flags = IORESOURCE_MEM,
  133. }
  134. };
  135. static struct platform_device acs5k_device_nor = {
  136. .name = "physmap-flash",
  137. .id = -1,
  138. .num_resources = ARRAY_SIZE(acs5k_nor_resource),
  139. .resource = acs5k_nor_resource,
  140. .dev = {
  141. .platform_data = &acs5k_nor_pdata,
  142. },
  143. };
  144. static void __init acs5k_register_nor(void)
  145. {
  146. int ret;
  147. if (acs5k_nor_partitions[0].mask_flags == 0)
  148. printk(KERN_WARNING "Warning: Unprotecting bootloader and configuration partition\n");
  149. ret = platform_device_register(&acs5k_device_nor);
  150. if (ret < 0)
  151. printk(KERN_ERR "failed to register physmap-flash device\n");
  152. }
  153. static int __init acs5k_protection_setup(char *s)
  154. {
  155. /* We can't allocate anything here but we should be able
  156. * to trivially parse s and decide if we can protect the
  157. * bootloader partition or not
  158. */
  159. if (strcmp(s, "no") == 0)
  160. acs5k_nor_partitions[0].mask_flags = 0;
  161. return 1;
  162. }
  163. __setup("protect_bootloader=", acs5k_protection_setup);
  164. static void __init acs5k_init_gpio(void)
  165. {
  166. int i;
  167. ks8695_register_gpios();
  168. for (i = 0; i < 4; ++i)
  169. gpio_request(i, "ACS5K IRQ");
  170. gpio_request(7, "ACS5K KS_FRDY");
  171. for (i = 8; i < 16; ++i)
  172. gpio_request(i, "ACS5K Unused");
  173. gpio_request(3, "ACS5K CAN Control");
  174. gpio_request(6, "ACS5K Heartbeat");
  175. gpio_direction_output(3, 1); /* Default CAN_RESET high */
  176. gpio_direction_output(6, 0); /* Default KS8695_ACTIVE low */
  177. gpio_export(3, 0); /* export CAN_RESET as output only */
  178. gpio_export(6, 0); /* export KS8695_ACTIVE as output only */
  179. }
  180. static void __init acs5k_init(void)
  181. {
  182. acs5k_init_gpio();
  183. /* Network device */
  184. ks8695_add_device_lan(); /* eth0 = LAN */
  185. ks8695_add_device_wan(); /* ethX = WAN */
  186. /* NOR devices */
  187. acs5k_register_nor();
  188. /* I2C bus */
  189. acs5k_i2c_init();
  190. }
  191. MACHINE_START(ACS5K, "Brivo Systems LLC ACS-5000 Master board")
  192. /* Maintainer: Simtec Electronics. */
  193. .boot_params = KS8695_SDRAM_PA + 0x100,
  194. .map_io = ks8695_map_io,
  195. .init_irq = ks8695_init_irq,
  196. .init_machine = acs5k_init,
  197. .timer = &ks8695_timer,
  198. MACHINE_END