laguna.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. /*
  2. * Gateworks Corporation Laguna Platform
  3. *
  4. * Copyright 2000 Deep Blue Solutions Ltd
  5. * Copyright 2008 ARM Limited
  6. * Copyright 2008 Cavium Networks
  7. * Scott Shu
  8. * Copyright 2010 MontaVista Software, LLC.
  9. * Anton Vorontsov <avorontsov@mvista.com>
  10. * Copyright 2011 Gateworks Corporation
  11. * Chris Lang <clang@gateworks.com>
  12. * Copyright 2012-2013 Gateworks Corporation
  13. * Tim Harvey <tharvey@gateworks.com>
  14. *
  15. * This file is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License, Version 2, as
  17. * published by the Free Software Foundation.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/compiler.h>
  22. #include <linux/io.h>
  23. #include <linux/irq.h>
  24. #include <linux/gpio.h>
  25. #include <linux/dma-mapping.h>
  26. #include <linux/serial_core.h>
  27. #include <linux/serial_8250.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/physmap.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <linux/leds.h>
  33. #include <linux/i2c.h>
  34. #include <linux/platform_data/at24.h>
  35. #include <linux/platform_data/pca953x.h>
  36. #include <linux/spi/spi.h>
  37. #include <linux/spi/flash.h>
  38. #include <linux/if_ether.h>
  39. #include <linux/pps-gpio.h>
  40. #include <linux/usb/ehci_pdriver.h>
  41. #include <linux/usb/ohci_pdriver.h>
  42. #include <linux/clk-provider.h>
  43. #include <linux/clkdev.h>
  44. #include <linux/platform_data/cns3xxx.h>
  45. #include <asm/setup.h>
  46. #include <asm/mach-types.h>
  47. #include <asm/mach/arch.h>
  48. #include <asm/mach/map.h>
  49. #include <asm/mach/time.h>
  50. #include <mach/gpio.h>
  51. #include "core.h"
  52. #include "devices.h"
  53. #include "cns3xxx.h"
  54. #include "pm.h"
  55. #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
  56. // Config 1 Bitmap
  57. #define ETH0_LOAD BIT(0)
  58. #define ETH1_LOAD BIT(1)
  59. #define ETH2_LOAD BIT(2)
  60. #define SATA0_LOAD BIT(3)
  61. #define SATA1_LOAD BIT(4)
  62. #define PCM_LOAD BIT(5)
  63. #define I2S_LOAD BIT(6)
  64. #define SPI0_LOAD BIT(7)
  65. #define SPI1_LOAD BIT(8)
  66. #define PCIE0_LOAD BIT(9)
  67. #define PCIE1_LOAD BIT(10)
  68. #define USB0_LOAD BIT(11)
  69. #define USB1_LOAD BIT(12)
  70. #define USB1_ROUTE BIT(13)
  71. #define SD_LOAD BIT(14)
  72. #define UART0_LOAD BIT(15)
  73. #define UART1_LOAD BIT(16)
  74. #define UART2_LOAD BIT(17)
  75. #define MPCI0_LOAD BIT(18)
  76. #define MPCI1_LOAD BIT(19)
  77. #define MPCI2_LOAD BIT(20)
  78. #define MPCI3_LOAD BIT(21)
  79. #define FP_BUT_LOAD BIT(22)
  80. #define FP_BUT_HEADER_LOAD BIT(23)
  81. #define FP_LED_LOAD BIT(24)
  82. #define FP_LED_HEADER_LOAD BIT(25)
  83. #define FP_TAMPER_LOAD BIT(26)
  84. #define HEADER_33V_LOAD BIT(27)
  85. #define SATA_POWER_LOAD BIT(28)
  86. #define FP_POWER_LOAD BIT(29)
  87. #define GPIO_HEADER_LOAD BIT(30)
  88. #define GSP_BAT_LOAD BIT(31)
  89. // Config 2 Bitmap
  90. #define FAN_LOAD BIT(0)
  91. #define SPI_FLASH_LOAD BIT(1)
  92. #define NOR_FLASH_LOAD BIT(2)
  93. #define GPS_LOAD BIT(3)
  94. #define SUPPLY_5V_LOAD BIT(6)
  95. #define SUPPLY_33V_LOAD BIT(7)
  96. struct laguna_board_info {
  97. char model[16];
  98. u32 config_bitmap;
  99. u32 config2_bitmap;
  100. u8 nor_flash_size;
  101. u8 spi_flash_size;
  102. };
  103. static struct laguna_board_info laguna_info __initdata;
  104. /*
  105. * NOR Flash
  106. */
  107. static struct mtd_partition laguna_nor_partitions[] = {
  108. {
  109. .name = "uboot",
  110. .size = SZ_256K,
  111. .offset = 0,
  112. .mask_flags = MTD_WRITEABLE,
  113. }, {
  114. .name = "params",
  115. .size = SZ_128K,
  116. .offset = SZ_256K,
  117. }, {
  118. .name = "firmware",
  119. .offset = SZ_256K + SZ_128K,
  120. },
  121. };
  122. static struct physmap_flash_data laguna_nor_pdata = {
  123. .width = 2,
  124. .parts = laguna_nor_partitions,
  125. .nr_parts = ARRAY_SIZE(laguna_nor_partitions),
  126. };
  127. static struct resource laguna_nor_res = {
  128. .start = CNS3XXX_FLASH_BASE,
  129. .end = CNS3XXX_FLASH_BASE + SZ_128M - 1,
  130. .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
  131. };
  132. static struct platform_device laguna_nor_pdev = {
  133. .name = "physmap-flash",
  134. .id = 0,
  135. .resource = &laguna_nor_res,
  136. .num_resources = 1,
  137. .dev = {
  138. .platform_data = &laguna_nor_pdata,
  139. },
  140. };
  141. /*
  142. * SPI
  143. */
  144. static struct mtd_partition laguna_spi_partitions[] = {
  145. {
  146. .name = "uboot",
  147. .size = SZ_256K,
  148. .offset = 0,
  149. .mask_flags = MTD_WRITEABLE,
  150. }, {
  151. .name = "params",
  152. .size = SZ_256K,
  153. .offset = SZ_256K,
  154. }, {
  155. .name = "firmware",
  156. .offset = SZ_512K,
  157. },
  158. };
  159. static struct flash_platform_data laguna_spi_pdata = {
  160. .parts = laguna_spi_partitions,
  161. .nr_parts = ARRAY_SIZE(laguna_spi_partitions),
  162. };
  163. static struct spi_board_info __initdata laguna_spi_devices[] = {
  164. {
  165. .modalias = "m25p80",
  166. .platform_data = &laguna_spi_pdata,
  167. .max_speed_hz = 50000000,
  168. .bus_num = 1,
  169. .chip_select = 0,
  170. },
  171. };
  172. static struct resource laguna_spi_resource = {
  173. .start = CNS3XXX_SSP_BASE + 0x40,
  174. .end = CNS3XXX_SSP_BASE + 0x6f,
  175. .flags = IORESOURCE_MEM,
  176. };
  177. static struct platform_device laguna_spi_controller = {
  178. .name = "cns3xxx_spi",
  179. .resource = &laguna_spi_resource,
  180. .num_resources = 1,
  181. };
  182. /*
  183. * LED's
  184. */
  185. static struct gpio_led laguna_gpio_leds[] = {
  186. {
  187. .name = "user1", /* Green Led */
  188. .gpio = 115,
  189. .active_low = 1,
  190. },{
  191. .name = "user2", /* Red Led */
  192. .gpio = 114,
  193. .active_low = 1,
  194. },{
  195. .name = "pwr1", /* Green Led */
  196. .gpio = 116,
  197. .active_low = 1,
  198. },{
  199. .name = "pwr2", /* Yellow Led */
  200. .gpio = 117,
  201. .active_low = 1,
  202. },{
  203. .name = "txd1", /* Green Led */
  204. .gpio = 118,
  205. .active_low = 1,
  206. },{
  207. .name = "txd2", /* Yellow Led */
  208. .gpio = 119,
  209. .active_low = 1,
  210. },{
  211. .name = "rxd1", /* Green Led */
  212. .gpio = 120,
  213. .active_low = 1,
  214. },{
  215. .name = "rxd2", /* Yellow Led */
  216. .gpio = 121,
  217. .active_low = 1,
  218. },{
  219. .name = "ser1", /* Green Led */
  220. .gpio = 122,
  221. .active_low = 1,
  222. },{
  223. .name = "ser2", /* Yellow Led */
  224. .gpio = 123,
  225. .active_low = 1,
  226. },{
  227. .name = "enet1", /* Green Led */
  228. .gpio = 124,
  229. .active_low = 1,
  230. },{
  231. .name = "enet2", /* Yellow Led */
  232. .gpio = 125,
  233. .active_low = 1,
  234. },{
  235. .name = "sig1_1", /* Green Led */
  236. .gpio = 126,
  237. .active_low = 1,
  238. },{
  239. .name = "sig1_2", /* Yellow Led */
  240. .gpio = 127,
  241. .active_low = 1,
  242. },{
  243. .name = "sig2_1", /* Green Led */
  244. .gpio = 128,
  245. .active_low = 1,
  246. },{
  247. .name = "sig2_2", /* Yellow Led */
  248. .gpio = 129,
  249. .active_low = 1,
  250. },{
  251. .name = "sig3_1", /* Green Led */
  252. .gpio = 130,
  253. .active_low = 1,
  254. },{
  255. .name = "sig3_2", /* Yellow Led */
  256. .gpio = 131,
  257. .active_low = 1,
  258. },{
  259. .name = "net1", /*Green Led */
  260. .gpio = 109,
  261. .active_low = 1,
  262. },{
  263. .name = "net2", /* Red Led */
  264. .gpio = 110,
  265. .active_low = 1,
  266. },{
  267. .name = "mod1", /* Green Led */
  268. .gpio = 111,
  269. .active_low = 1,
  270. },{
  271. .name = "mod2", /* Red Led */
  272. .gpio = 112,
  273. .active_low = 1,
  274. },
  275. };
  276. static struct gpio_led_platform_data laguna_gpio_leds_data = {
  277. .num_leds = 22,
  278. .leds = laguna_gpio_leds,
  279. };
  280. static struct platform_device laguna_gpio_leds_device = {
  281. .name = "leds-gpio",
  282. .id = PLATFORM_DEVID_NONE,
  283. .dev.platform_data = &laguna_gpio_leds_data,
  284. };
  285. /*
  286. * Ethernet
  287. */
  288. static struct cns3xxx_plat_info laguna_net_data = {
  289. .ports = 0,
  290. .phy = {
  291. 0,
  292. 1,
  293. 2,
  294. },
  295. };
  296. static struct resource laguna_net_resource[] = {
  297. {
  298. .name = "eth0_mem",
  299. .start = CNS3XXX_SWITCH_BASE,
  300. .end = CNS3XXX_SWITCH_BASE + SZ_4K - 1,
  301. .flags = IORESOURCE_MEM
  302. }, {
  303. .name = "eth_rx",
  304. .start = IRQ_CNS3XXX_SW_R0RXC,
  305. .end = IRQ_CNS3XXX_SW_R0RXC,
  306. .flags = IORESOURCE_IRQ
  307. }, {
  308. .name = "eth_stat",
  309. .start = IRQ_CNS3XXX_SW_STATUS,
  310. .end = IRQ_CNS3XXX_SW_STATUS,
  311. .flags = IORESOURCE_IRQ
  312. }
  313. };
  314. static u64 laguna_net_dmamask = DMA_BIT_MASK(32);
  315. static struct platform_device laguna_net_device = {
  316. .name = "cns3xxx_eth",
  317. .id = 0,
  318. .resource = laguna_net_resource,
  319. .num_resources = ARRAY_SIZE(laguna_net_resource),
  320. .dev = {
  321. .dma_mask = &laguna_net_dmamask,
  322. .coherent_dma_mask = DMA_BIT_MASK(32),
  323. .platform_data = &laguna_net_data,
  324. }
  325. };
  326. /*
  327. * UART
  328. */
  329. static void __init laguna_early_serial_setup(void)
  330. {
  331. #ifdef CONFIG_SERIAL_8250_CONSOLE
  332. static struct uart_port laguna_serial_port = {
  333. .membase = (void __iomem *)CNS3XXX_UART0_BASE_VIRT,
  334. .mapbase = CNS3XXX_UART0_BASE,
  335. .irq = IRQ_CNS3XXX_UART0,
  336. .iotype = UPIO_MEM,
  337. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
  338. .regshift = 2,
  339. .uartclk = 24000000,
  340. .line = 0,
  341. .type = PORT_16550A,
  342. .fifosize = 16,
  343. };
  344. early_serial_setup(&laguna_serial_port);
  345. #endif
  346. }
  347. static struct resource laguna_uart_resources[] = {
  348. {
  349. .start = CNS3XXX_UART0_BASE,
  350. .end = CNS3XXX_UART0_BASE + SZ_4K - 1,
  351. .flags = IORESOURCE_MEM
  352. },{
  353. .start = CNS3XXX_UART1_BASE,
  354. .end = CNS3XXX_UART1_BASE + SZ_4K - 1,
  355. .flags = IORESOURCE_MEM
  356. },{
  357. .start = CNS3XXX_UART2_BASE,
  358. .end = CNS3XXX_UART2_BASE + SZ_4K - 1,
  359. .flags = IORESOURCE_MEM
  360. },
  361. };
  362. static struct plat_serial8250_port laguna_uart_data[] = {
  363. {
  364. .mapbase = (CNS3XXX_UART0_BASE),
  365. .irq = IRQ_CNS3XXX_UART0,
  366. .iotype = UPIO_MEM,
  367. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST | UPF_IOREMAP,
  368. .regshift = 2,
  369. .uartclk = 24000000,
  370. .type = PORT_16550A,
  371. },{
  372. .mapbase = (CNS3XXX_UART1_BASE),
  373. .irq = IRQ_CNS3XXX_UART1,
  374. .iotype = UPIO_MEM,
  375. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST | UPF_IOREMAP,
  376. .regshift = 2,
  377. .uartclk = 24000000,
  378. .type = PORT_16550A,
  379. },{
  380. .mapbase = (CNS3XXX_UART2_BASE),
  381. .irq = IRQ_CNS3XXX_UART2,
  382. .iotype = UPIO_MEM,
  383. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST | UPF_IOREMAP,
  384. .regshift = 2,
  385. .uartclk = 24000000,
  386. .type = PORT_16550A,
  387. },
  388. { },
  389. };
  390. static struct platform_device laguna_uart = {
  391. .name = "serial8250",
  392. .id = PLAT8250_DEV_PLATFORM,
  393. .dev.platform_data = laguna_uart_data,
  394. .num_resources = 3,
  395. .resource = laguna_uart_resources
  396. };
  397. /*
  398. * USB
  399. */
  400. static struct resource cns3xxx_usb_ehci_resources[] = {
  401. [0] = {
  402. .start = CNS3XXX_USB_BASE,
  403. .end = CNS3XXX_USB_BASE + SZ_16M - 1,
  404. .flags = IORESOURCE_MEM,
  405. },
  406. [1] = {
  407. .start = IRQ_CNS3XXX_USB_EHCI,
  408. .flags = IORESOURCE_IRQ,
  409. },
  410. };
  411. static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32);
  412. static int csn3xxx_usb_power_on(struct platform_device *pdev)
  413. {
  414. /*
  415. * EHCI and OHCI share the same clock and power,
  416. * resetting twice would cause the 1st controller been reset.
  417. * Therefore only do power up at the first up device, and
  418. * power down at the last down device.
  419. *
  420. * Set USB AHB INCR length to 16
  421. */
  422. if (atomic_inc_return(&usb_pwr_ref) == 1) {
  423. cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
  424. cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
  425. cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
  426. __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
  427. MISC_CHIP_CONFIG_REG);
  428. }
  429. return 0;
  430. }
  431. static void csn3xxx_usb_power_off(struct platform_device *pdev)
  432. {
  433. /*
  434. * EHCI and OHCI share the same clock and power,
  435. * resetting twice would cause the 1st controller been reset.
  436. * Therefore only do power up at the first up device, and
  437. * power down at the last down device.
  438. */
  439. if (atomic_dec_return(&usb_pwr_ref) == 0)
  440. cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
  441. }
  442. static struct usb_ehci_pdata cns3xxx_usb_ehci_pdata = {
  443. .power_on = csn3xxx_usb_power_on,
  444. .power_off = csn3xxx_usb_power_off,
  445. };
  446. static struct platform_device cns3xxx_usb_ehci_device = {
  447. .name = "ehci-platform",
  448. .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources),
  449. .resource = cns3xxx_usb_ehci_resources,
  450. .dev = {
  451. .dma_mask = &cns3xxx_usb_ehci_dma_mask,
  452. .coherent_dma_mask = DMA_BIT_MASK(32),
  453. .platform_data = &cns3xxx_usb_ehci_pdata,
  454. },
  455. };
  456. static struct resource cns3xxx_usb_ohci_resources[] = {
  457. [0] = {
  458. .start = CNS3XXX_USB_OHCI_BASE,
  459. .end = CNS3XXX_USB_OHCI_BASE + SZ_16M - 1,
  460. .flags = IORESOURCE_MEM,
  461. },
  462. [1] = {
  463. .start = IRQ_CNS3XXX_USB_OHCI,
  464. .flags = IORESOURCE_IRQ,
  465. },
  466. };
  467. static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32);
  468. static struct usb_ohci_pdata cns3xxx_usb_ohci_pdata = {
  469. .num_ports = 1,
  470. .power_on = csn3xxx_usb_power_on,
  471. .power_off = csn3xxx_usb_power_off,
  472. };
  473. static struct platform_device cns3xxx_usb_ohci_device = {
  474. .name = "ohci-platform",
  475. .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources),
  476. .resource = cns3xxx_usb_ohci_resources,
  477. .dev = {
  478. .dma_mask = &cns3xxx_usb_ohci_dma_mask,
  479. .coherent_dma_mask = DMA_BIT_MASK(32),
  480. .platform_data = &cns3xxx_usb_ohci_pdata,
  481. },
  482. };
  483. static struct resource cns3xxx_usb_otg_resources[] = {
  484. [0] = {
  485. .start = CNS3XXX_USBOTG_BASE,
  486. .end = CNS3XXX_USBOTG_BASE + SZ_16M - 1,
  487. .flags = IORESOURCE_MEM,
  488. },
  489. [1] = {
  490. .start = IRQ_CNS3XXX_USB_OTG,
  491. .flags = IORESOURCE_IRQ,
  492. },
  493. };
  494. static u64 cns3xxx_usb_otg_dma_mask = DMA_BIT_MASK(32);
  495. static struct platform_device cns3xxx_usb_otg_device = {
  496. .name = "dwc2",
  497. .num_resources = ARRAY_SIZE(cns3xxx_usb_otg_resources),
  498. .resource = cns3xxx_usb_otg_resources,
  499. .dev = {
  500. .dma_mask = &cns3xxx_usb_otg_dma_mask,
  501. .coherent_dma_mask = DMA_BIT_MASK(32),
  502. },
  503. };
  504. /*
  505. * I2C
  506. */
  507. static struct resource laguna_i2c_resource[] = {
  508. {
  509. .start = CNS3XXX_SSP_BASE + 0x20,
  510. .end = CNS3XXX_SSP_BASE + 0x3f,
  511. .flags = IORESOURCE_MEM,
  512. },{
  513. .start = IRQ_CNS3XXX_I2C,
  514. .flags = IORESOURCE_IRQ,
  515. },
  516. };
  517. static struct platform_device laguna_i2c_controller = {
  518. .name = "cns3xxx-i2c",
  519. .num_resources = 2,
  520. .resource = laguna_i2c_resource,
  521. };
  522. static struct memory_accessor *at24_mem_acc;
  523. static void at24_setup(struct memory_accessor *mem_acc, void *context)
  524. {
  525. char buf[16];
  526. at24_mem_acc = mem_acc;
  527. /* Read MAC addresses */
  528. if (at24_mem_acc->read(at24_mem_acc, buf, 0x100, 6) == 6)
  529. memcpy(&laguna_net_data.hwaddr[0], buf, ETH_ALEN);
  530. if (at24_mem_acc->read(at24_mem_acc, buf, 0x106, 6) == 6)
  531. memcpy(&laguna_net_data.hwaddr[1], buf, ETH_ALEN);
  532. if (at24_mem_acc->read(at24_mem_acc, buf, 0x10C, 6) == 6)
  533. memcpy(&laguna_net_data.hwaddr[2], buf, ETH_ALEN);
  534. if (at24_mem_acc->read(at24_mem_acc, buf, 0x112, 6) == 6)
  535. memcpy(&laguna_net_data.hwaddr[3], buf, ETH_ALEN);
  536. /* Read out Model Information */
  537. if (at24_mem_acc->read(at24_mem_acc, buf, 0x130, 16) == 16)
  538. memcpy(&laguna_info.model, buf, 16);
  539. if (at24_mem_acc->read(at24_mem_acc, buf, 0x140, 1) == 1)
  540. memcpy(&laguna_info.nor_flash_size, buf, 1);
  541. if (at24_mem_acc->read(at24_mem_acc, buf, 0x141, 1) == 1)
  542. memcpy(&laguna_info.spi_flash_size, buf, 1);
  543. if (at24_mem_acc->read(at24_mem_acc, buf, 0x142, 4) == 4)
  544. memcpy(&laguna_info.config_bitmap, buf, 4);
  545. if (at24_mem_acc->read(at24_mem_acc, buf, 0x146, 4) == 4)
  546. memcpy(&laguna_info.config2_bitmap, buf, 4);
  547. };
  548. static struct at24_platform_data laguna_eeprom_info = {
  549. .byte_len = 1024,
  550. .page_size = 16,
  551. .flags = AT24_FLAG_READONLY,
  552. .setup = at24_setup,
  553. };
  554. static struct pca953x_platform_data laguna_pca_data = {
  555. .gpio_base = 100,
  556. .irq_base = -1,
  557. };
  558. static struct pca953x_platform_data laguna_pca2_data = {
  559. .gpio_base = 116,
  560. .irq_base = -1,
  561. };
  562. static struct i2c_board_info __initdata laguna_i2c_devices[] = {
  563. {
  564. I2C_BOARD_INFO("pca9555", 0x23),
  565. .platform_data = &laguna_pca_data,
  566. },{
  567. I2C_BOARD_INFO("pca9555", 0x27),
  568. .platform_data = &laguna_pca2_data,
  569. },{
  570. I2C_BOARD_INFO("gsp", 0x29),
  571. },{
  572. I2C_BOARD_INFO ("24c08",0x50),
  573. .platform_data = &laguna_eeprom_info,
  574. },{
  575. I2C_BOARD_INFO("ds1672", 0x68),
  576. },
  577. };
  578. /*
  579. * Watchdog
  580. */
  581. static struct resource laguna_watchdog_resources[] = {
  582. [0] = {
  583. .start = CNS3XXX_TC11MP_TWD_BASE + 0x100, // CPU0 watchdog
  584. .end = CNS3XXX_TC11MP_TWD_BASE + SZ_4K - 1,
  585. .flags = IORESOURCE_MEM,
  586. },
  587. };
  588. static struct platform_device laguna_watchdog = {
  589. .name = "mpcore_wdt",
  590. .id = PLATFORM_DEVID_NONE,
  591. .num_resources = ARRAY_SIZE(laguna_watchdog_resources),
  592. .resource = laguna_watchdog_resources,
  593. };
  594. /*
  595. * GPS PPS
  596. */
  597. static struct pps_gpio_platform_data laguna_pps_data = {
  598. .gpio_pin = 0,
  599. .gpio_label = "GPS_PPS",
  600. .assert_falling_edge = 0,
  601. .capture_clear = 0,
  602. };
  603. static struct platform_device laguna_pps_device = {
  604. .name = "pps-gpio",
  605. .id = PLATFORM_DEVID_NONE,
  606. .dev.platform_data = &laguna_pps_data,
  607. };
  608. /*
  609. * GPIO
  610. */
  611. static struct gpio laguna_gpio_gw2391[] = {
  612. { 0, GPIOF_IN , "*GPS_PPS" },
  613. { 1, GPIOF_IN , "*GSC_IRQ#" },
  614. { 2, GPIOF_IN , "*USB_FAULT#" },
  615. { 5, GPIOF_OUT_INIT_LOW , "*USB0_PCI_SEL" },
  616. { 6, GPIOF_OUT_INIT_HIGH, "*USB_VBUS_EN" },
  617. { 7, GPIOF_OUT_INIT_LOW , "*USB1_PCI_SEL" },
  618. { 8, GPIOF_OUT_INIT_HIGH, "*PERST#" },
  619. { 9, GPIOF_OUT_INIT_LOW , "*FP_SER_EN#" },
  620. { 100, GPIOF_IN , "*USER_PB#" },
  621. { 103, GPIOF_OUT_INIT_HIGH, "*V5_EN" },
  622. { 108, GPIOF_IN , "DIO0" },
  623. { 109, GPIOF_IN , "DIO1" },
  624. { 110, GPIOF_IN , "DIO2" },
  625. { 111, GPIOF_IN , "DIO3" },
  626. { 112, GPIOF_IN , "DIO4" },
  627. };
  628. static struct gpio laguna_gpio_gw2388[] = {
  629. { 0, GPIOF_IN , "*GPS_PPS" },
  630. { 1, GPIOF_IN , "*GSC_IRQ#" },
  631. { 3, GPIOF_IN , "*USB_FAULT#" },
  632. { 6, GPIOF_OUT_INIT_HIGH, "*USB_VBUS_EN" },
  633. { 7, GPIOF_OUT_INIT_LOW , "*GSM_SEL0" },
  634. { 8, GPIOF_OUT_INIT_LOW , "*GSM_SEL1" },
  635. { 9, GPIOF_OUT_INIT_LOW , "*FP_SER_EN" },
  636. { 100, GPIOF_OUT_INIT_HIGH, "*USER_PB#" },
  637. { 108, GPIOF_IN , "DIO0" },
  638. { 109, GPIOF_IN , "DIO1" },
  639. { 110, GPIOF_IN , "DIO2" },
  640. { 111, GPIOF_IN , "DIO3" },
  641. { 112, GPIOF_IN , "DIO4" },
  642. };
  643. static struct gpio laguna_gpio_gw2387[] = {
  644. { 0, GPIOF_IN , "*GPS_PPS" },
  645. { 1, GPIOF_IN , "*GSC_IRQ#" },
  646. { 2, GPIOF_IN , "*USB_FAULT#" },
  647. { 5, GPIOF_OUT_INIT_LOW , "*USB_PCI_SEL" },
  648. { 6, GPIOF_OUT_INIT_HIGH, "*USB_VBUS_EN" },
  649. { 7, GPIOF_OUT_INIT_LOW , "*GSM_SEL0" },
  650. { 8, GPIOF_OUT_INIT_LOW , "*GSM_SEL1" },
  651. { 9, GPIOF_OUT_INIT_LOW , "*FP_SER_EN" },
  652. { 100, GPIOF_IN , "*USER_PB#" },
  653. { 103, GPIOF_OUT_INIT_HIGH, "*V5_EN" },
  654. { 108, GPIOF_IN , "DIO0" },
  655. { 109, GPIOF_IN , "DIO1" },
  656. { 110, GPIOF_IN , "DIO2" },
  657. { 111, GPIOF_IN , "DIO3" },
  658. { 112, GPIOF_IN , "DIO4" },
  659. { 113, GPIOF_IN , "DIO5" },
  660. };
  661. static struct gpio laguna_gpio_gw2386[] = {
  662. { 0, GPIOF_IN , "*GPS_PPS" },
  663. { 2, GPIOF_IN , "*USB_FAULT#" },
  664. { 6, GPIOF_OUT_INIT_LOW , "*USB_PCI_SEL" },
  665. { 7, GPIOF_OUT_INIT_LOW , "*GSM_SEL0" },
  666. { 8, GPIOF_OUT_INIT_LOW , "*GSM_SEL1" },
  667. { 9, GPIOF_OUT_INIT_LOW , "*FP_SER_EN" },
  668. { 108, GPIOF_IN , "DIO0" },
  669. { 109, GPIOF_IN , "DIO1" },
  670. { 110, GPIOF_IN , "DIO2" },
  671. { 111, GPIOF_IN , "DIO3" },
  672. { 112, GPIOF_IN , "DIO4" },
  673. { 113, GPIOF_IN , "DIO5" },
  674. };
  675. static struct gpio laguna_gpio_gw2385[] = {
  676. { 0, GPIOF_IN , "*GSC_IRQ#" },
  677. { 1, GPIOF_OUT_INIT_HIGH, "*USB_HST_VBUS_EN" },
  678. { 2, GPIOF_IN , "*USB_HST_FAULT#" },
  679. { 5, GPIOF_IN , "*USB_OTG_FAULT#" },
  680. { 6, GPIOF_OUT_INIT_LOW , "*USB_HST_PCI_SEL" },
  681. { 7, GPIOF_OUT_INIT_LOW , "*GSM_SEL0" },
  682. { 8, GPIOF_OUT_INIT_LOW , "*GSM_SEL1" },
  683. { 9, GPIOF_OUT_INIT_LOW , "*SER_EN" },
  684. { 10, GPIOF_IN, "*USER_PB#" },
  685. { 11, GPIOF_OUT_INIT_HIGH, "*PERST#" },
  686. { 100, GPIOF_IN , "*USER_PB#" },
  687. { 103, GPIOF_OUT_INIT_HIGH, "V5_EN" },
  688. };
  689. static struct gpio laguna_gpio_gw2384[] = {
  690. { 0, GPIOF_IN , "*GSC_IRQ#" },
  691. { 1, GPIOF_OUT_INIT_HIGH, "*USB_HST_VBUS_EN" },
  692. { 2, GPIOF_IN , "*USB_HST_FAULT#" },
  693. { 5, GPIOF_IN , "*USB_OTG_FAULT#" },
  694. { 6, GPIOF_OUT_INIT_LOW , "*USB_HST_PCI_SEL" },
  695. { 7, GPIOF_OUT_INIT_LOW , "*GSM_SEL0" },
  696. { 8, GPIOF_OUT_INIT_LOW , "*GSM_SEL1" },
  697. { 9, GPIOF_OUT_INIT_LOW , "*FP_SER_EN" },
  698. { 12, GPIOF_OUT_INIT_LOW , "J10_DIOLED0" },
  699. { 13, GPIOF_OUT_INIT_HIGH, "*I2CMUX_RST#" },
  700. { 14, GPIOF_OUT_INIT_LOW , "J10_DIOLED1" },
  701. { 15, GPIOF_OUT_INIT_LOW , "J10_DIOLED2" },
  702. { 100, GPIOF_IN , "*USER_PB#" },
  703. { 103, GPIOF_OUT_INIT_HIGH, "V5_EN" },
  704. { 108, GPIOF_IN , "J9_DIOGSC0" },
  705. };
  706. static struct gpio laguna_gpio_gw2383[] = {
  707. { 0, GPIOF_IN , "*GPS_PPS" },
  708. { 1, GPIOF_IN , "*GSC_IRQ#" },
  709. { 2, GPIOF_OUT_INIT_HIGH, "*PCIE_RST#" },
  710. { 3, GPIOF_IN , "GPIO0" },
  711. { 8, GPIOF_IN , "GPIO1" },
  712. { 100, GPIOF_IN , "DIO0" },
  713. { 101, GPIOF_IN , "DIO1" },
  714. { 108, GPIOF_IN , "*USER_PB#" },
  715. };
  716. static struct gpio laguna_gpio_gw2382[] = {
  717. { 0, GPIOF_IN , "*GPS_PPS" },
  718. { 1, GPIOF_IN , "*GSC_IRQ#" },
  719. { 2, GPIOF_OUT_INIT_HIGH, "*PCIE_RST#" },
  720. { 3, GPIOF_IN , "GPIO0" },
  721. { 4, GPIOF_IN , "GPIO1" },
  722. { 9, GPIOF_OUT_INIT_HIGH, "*USB_VBUS_EN" },
  723. { 10, GPIOF_OUT_INIT_HIGH, "*USB_PCI_SEL#" },
  724. { 100, GPIOF_IN , "DIO0" },
  725. { 101, GPIOF_IN , "DIO1" },
  726. { 108, GPIOF_IN , "*USER_PB#" },
  727. };
  728. static struct gpio laguna_gpio_gw2380[] = {
  729. { 0, GPIOF_IN , "*GPS_PPS" },
  730. { 1, GPIOF_IN , "*GSC_IRQ#" },
  731. { 3, GPIOF_IN , "GPIO0" },
  732. { 8, GPIOF_IN , "GPIO1" },
  733. { 100, GPIOF_IN , "DIO0" },
  734. { 101, GPIOF_IN , "DIO1" },
  735. { 102, GPIOF_IN , "DIO2" },
  736. { 103, GPIOF_IN , "DIO3" },
  737. { 108, GPIOF_IN , "*USER_PB#" },
  738. };
  739. /*
  740. * Initialization
  741. */
  742. static void __init laguna_init(void)
  743. {
  744. struct clk *clk;
  745. u32 __iomem *reg;
  746. clk = clk_register_fixed_rate(NULL, "cpu", NULL,
  747. CLK_IS_ROOT | CLK_IGNORE_UNUSED,
  748. cns3xxx_cpu_clock() * (1000000 / 8));
  749. clk_register_clkdev(clk, "cpu", NULL);
  750. platform_device_register(&laguna_watchdog);
  751. platform_device_register(&laguna_i2c_controller);
  752. /* Set I2C 0-3 drive strength to 21 mA */
  753. reg = MISC_IO_PAD_DRIVE_STRENGTH_CTRL_B;
  754. *reg |= 0x300;
  755. /* Enable SCL/SDA for I2C */
  756. reg = MISC_GPIOB_PIN_ENABLE_REG;
  757. *reg |= BIT(12) | BIT(13);
  758. /* Enable MMC/SD pins */
  759. *reg |= BIT(7) | BIT(8) | BIT(9) | BIT(10) | BIT(11);
  760. cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_SPI_PCM_I2C);
  761. cns3xxx_pwr_power_up(1 << PM_CLK_GATE_REG_OFFSET_SPI_PCM_I2C);
  762. cns3xxx_pwr_soft_rst(1 << PM_CLK_GATE_REG_OFFSET_SPI_PCM_I2C);
  763. cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SPI_PCM_I2C));
  764. cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SPI_PCM_I2C));
  765. i2c_register_board_info(0, ARRAY_AND_SIZE(laguna_i2c_devices));
  766. pm_power_off = cns3xxx_power_off;
  767. }
  768. static struct map_desc laguna_io_desc[] __initdata = {
  769. {
  770. .virtual = CNS3XXX_UART0_BASE_VIRT,
  771. .pfn = __phys_to_pfn(CNS3XXX_UART0_BASE),
  772. .length = SZ_4K,
  773. .type = MT_DEVICE,
  774. },
  775. };
  776. static void __init laguna_map_io(void)
  777. {
  778. cns3xxx_map_io();
  779. iotable_init(ARRAY_AND_SIZE(laguna_io_desc));
  780. laguna_early_serial_setup();
  781. }
  782. static int laguna_register_gpio(struct gpio *array, size_t num)
  783. {
  784. int i, err, ret;
  785. ret = 0;
  786. for (i = 0; i < num; i++, array++) {
  787. const char *label = array->label;
  788. if (label[0] == '*')
  789. label++;
  790. err = gpio_request_one(array->gpio, array->flags, label);
  791. if (err)
  792. ret = err;
  793. else {
  794. err = gpio_export(array->gpio, array->label[0] != '*');
  795. }
  796. }
  797. return ret;
  798. }
  799. /* allow disabling of external isolated PCIe IRQs */
  800. static int cns3xxx_pciextirq = 1;
  801. static int __init cns3xxx_pciextirq_disable(char *s)
  802. {
  803. cns3xxx_pciextirq = 0;
  804. return 1;
  805. }
  806. __setup("noextirq", cns3xxx_pciextirq_disable);
  807. static int __init laguna_pcie_init_irq(void)
  808. {
  809. u32 __iomem *mem = (void __iomem *)(CNS3XXX_GPIOB_BASE_VIRT + 0x0004);
  810. u32 reg = (__raw_readl(mem) >> 26) & 0xf;
  811. int irqs[] = {
  812. IRQ_CNS3XXX_EXTERNAL_PIN0,
  813. IRQ_CNS3XXX_EXTERNAL_PIN1,
  814. IRQ_CNS3XXX_EXTERNAL_PIN2,
  815. 154,
  816. };
  817. if (!machine_is_gw2388())
  818. return 0;
  819. /* Verify GPIOB[26:29] == 0001b indicating support for ext irqs */
  820. if (cns3xxx_pciextirq && reg != 1)
  821. cns3xxx_pciextirq = 0;
  822. if (cns3xxx_pciextirq) {
  823. printk("laguna: using isolated PCI interrupts:"
  824. " irq%d/irq%d/irq%d/irq%d\n",
  825. irqs[0], irqs[1], irqs[2], irqs[3]);
  826. cns3xxx_pcie_set_irqs(0, irqs);
  827. } else {
  828. printk("laguna: using shared PCI interrupts: irq%d\n",
  829. IRQ_CNS3XXX_PCIE0_DEVICE);
  830. }
  831. return 0;
  832. }
  833. subsys_initcall(laguna_pcie_init_irq);
  834. static int __init laguna_model_setup(void)
  835. {
  836. u32 __iomem *mem;
  837. u32 reg;
  838. if (!machine_is_gw2388())
  839. return 0;
  840. printk("Running on Gateworks Laguna %s\n", laguna_info.model);
  841. cns3xxx_gpio_init( 0, 32, CNS3XXX_GPIOA_BASE_VIRT, IRQ_CNS3XXX_GPIOA,
  842. NR_IRQS_CNS3XXX);
  843. /*
  844. * If pcie external interrupts are supported and desired
  845. * configure IRQ types and configure pin function.
  846. * Note that cns3xxx_pciextirq is enabled by default, but can be
  847. * unset via the 'noextirq' kernel param or by laguna_pcie_init() if
  848. * the baseboard model does not support this hardware feature.
  849. */
  850. if (cns3xxx_pciextirq) {
  851. mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0018);
  852. reg = __raw_readl(mem);
  853. /* GPIO26 is gpio, EXT_INT[0:2] not gpio func */
  854. reg &= ~0x3c000000;
  855. reg |= 0x38000000;
  856. __raw_writel(reg, mem);
  857. cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT,
  858. IRQ_CNS3XXX_GPIOB, NR_IRQS_CNS3XXX + 32);
  859. irq_set_irq_type(154, IRQ_TYPE_LEVEL_LOW);
  860. irq_set_irq_type(93, IRQ_TYPE_LEVEL_HIGH);
  861. irq_set_irq_type(94, IRQ_TYPE_LEVEL_HIGH);
  862. irq_set_irq_type(95, IRQ_TYPE_LEVEL_HIGH);
  863. } else {
  864. cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT,
  865. IRQ_CNS3XXX_GPIOB, NR_IRQS_CNS3XXX + 32);
  866. }
  867. if (strncmp(laguna_info.model, "GW", 2) == 0) {
  868. if (laguna_info.config_bitmap & ETH0_LOAD)
  869. laguna_net_data.ports |= BIT(0);
  870. if (laguna_info.config_bitmap & ETH1_LOAD)
  871. laguna_net_data.ports |= BIT(1);
  872. if (laguna_info.config_bitmap & ETH2_LOAD)
  873. laguna_net_data.ports |= BIT(2);
  874. if (laguna_net_data.ports)
  875. platform_device_register(&laguna_net_device);
  876. if ((laguna_info.config_bitmap & SATA0_LOAD) ||
  877. (laguna_info.config_bitmap & SATA1_LOAD))
  878. cns3xxx_ahci_init();
  879. if (laguna_info.config_bitmap & (USB0_LOAD)) {
  880. cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
  881. /* DRVVBUS pins share with GPIOA */
  882. mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0014);
  883. reg = __raw_readl(mem);
  884. reg |= 0x8;
  885. __raw_writel(reg, mem);
  886. /* Enable OTG */
  887. mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0808);
  888. reg = __raw_readl(mem);
  889. reg &= ~(1 << 10);
  890. __raw_writel(reg, mem);
  891. platform_device_register(&cns3xxx_usb_otg_device);
  892. }
  893. if (laguna_info.config_bitmap & (USB1_LOAD)) {
  894. platform_device_register(&cns3xxx_usb_ehci_device);
  895. platform_device_register(&cns3xxx_usb_ohci_device);
  896. }
  897. if (laguna_info.config_bitmap & (SD_LOAD))
  898. cns3xxx_sdhci_init();
  899. if (laguna_info.config_bitmap & (UART0_LOAD))
  900. laguna_uart.num_resources = 1;
  901. if (laguna_info.config_bitmap & (UART1_LOAD))
  902. laguna_uart.num_resources = 2;
  903. if (laguna_info.config_bitmap & (UART2_LOAD))
  904. laguna_uart.num_resources = 3;
  905. platform_device_register(&laguna_uart);
  906. if (laguna_info.config2_bitmap & (NOR_FLASH_LOAD)) {
  907. laguna_nor_partitions[2].size =
  908. (SZ_4M << laguna_info.nor_flash_size) -
  909. laguna_nor_partitions[2].offset;
  910. laguna_nor_res.end = CNS3XXX_FLASH_BASE +
  911. laguna_nor_partitions[2].offset +
  912. laguna_nor_partitions[2].size - 1;
  913. platform_device_register(&laguna_nor_pdev);
  914. }
  915. if (laguna_info.config2_bitmap & (SPI_FLASH_LOAD)) {
  916. laguna_spi_partitions[2].size =
  917. (SZ_2M << laguna_info.spi_flash_size) -
  918. laguna_spi_partitions[2].offset;
  919. spi_register_board_info(ARRAY_AND_SIZE(laguna_spi_devices));
  920. }
  921. if ((laguna_info.config_bitmap & SPI0_LOAD) ||
  922. (laguna_info.config_bitmap & SPI1_LOAD))
  923. platform_device_register(&laguna_spi_controller);
  924. if (laguna_info.config2_bitmap & GPS_LOAD)
  925. platform_device_register(&laguna_pps_device);
  926. /*
  927. * Do any model specific setup not known by the bitmap by matching
  928. * the first 6 characters of the model name
  929. */
  930. if ( (strncmp(laguna_info.model, "GW2388", 6) == 0)
  931. || (strncmp(laguna_info.model, "GW2389", 6) == 0) )
  932. {
  933. // configure GPIO's
  934. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2388));
  935. // configure LED's
  936. laguna_gpio_leds_data.num_leds = 2;
  937. } else if (strncmp(laguna_info.model, "GW2387", 6) == 0) {
  938. // configure GPIO's
  939. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2387));
  940. // configure LED's
  941. laguna_gpio_leds_data.num_leds = 2;
  942. } else if (strncmp(laguna_info.model, "GW2386", 6) == 0) {
  943. // configure GPIO's
  944. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2386));
  945. // configure LED's
  946. laguna_gpio_leds_data.num_leds = 2;
  947. } else if (strncmp(laguna_info.model, "GW2385", 6) == 0) {
  948. // configure GPIO's
  949. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2385));
  950. // configure LED's
  951. laguna_gpio_leds[0].gpio = 115;
  952. laguna_gpio_leds[1].gpio = 12;
  953. laguna_gpio_leds[1].name = "red";
  954. laguna_gpio_leds[1].active_low = 0,
  955. laguna_gpio_leds[2].gpio = 14;
  956. laguna_gpio_leds[2].name = "green";
  957. laguna_gpio_leds[2].active_low = 0,
  958. laguna_gpio_leds[3].gpio = 15;
  959. laguna_gpio_leds[3].name = "blue";
  960. laguna_gpio_leds[3].active_low = 0,
  961. laguna_gpio_leds_data.num_leds = 4;
  962. } else if ( (strncmp(laguna_info.model, "GW2384", 6) == 0)
  963. || (strncmp(laguna_info.model, "GW2394", 6) == 0) )
  964. {
  965. // configure GPIO's
  966. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2384));
  967. // configure LED's
  968. laguna_gpio_leds_data.num_leds = 1;
  969. } else if (strncmp(laguna_info.model, "GW2383", 6) == 0) {
  970. // configure GPIO's
  971. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2383));
  972. // configure LED's
  973. laguna_gpio_leds[0].gpio = 107;
  974. laguna_gpio_leds_data.num_leds = 1;
  975. } else if (strncmp(laguna_info.model, "GW2382", 6) == 0) {
  976. // configure GPIO's
  977. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2382));
  978. // configure LED's
  979. laguna_gpio_leds[0].gpio = 107;
  980. laguna_gpio_leds_data.num_leds = 1;
  981. } else if (strncmp(laguna_info.model, "GW2380", 6) == 0) {
  982. // configure GPIO's
  983. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2380));
  984. // configure LED's
  985. laguna_gpio_leds[0].gpio = 107;
  986. laguna_gpio_leds[1].gpio = 106;
  987. laguna_gpio_leds_data.num_leds = 2;
  988. } else if ( (strncmp(laguna_info.model, "GW2391", 6) == 0)
  989. || (strncmp(laguna_info.model, "GW2393", 6) == 0) )
  990. {
  991. // configure GPIO's
  992. laguna_register_gpio(ARRAY_AND_SIZE(laguna_gpio_gw2391));
  993. // configure LED's
  994. laguna_gpio_leds_data.num_leds = 2;
  995. }
  996. platform_device_register(&laguna_gpio_leds_device);
  997. } else {
  998. // Do some defaults here, not sure what yet
  999. }
  1000. return 0;
  1001. }
  1002. late_initcall(laguna_model_setup);
  1003. MACHINE_START(GW2388, "Gateworks Corporation Laguna Platform")
  1004. .smp = smp_ops(cns3xxx_smp_ops),
  1005. .atag_offset = 0x100,
  1006. .map_io = laguna_map_io,
  1007. .init_irq = cns3xxx_init_irq,
  1008. .init_time = cns3xxx_timer_init,
  1009. .init_machine = laguna_init,
  1010. .init_late = cns3xxx_pcie_init_late,
  1011. .restart = cns3xxx_restart,
  1012. MACHINE_END