Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 1 | /* |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2016 Zhang, Keguang <keguang.zhang@gmail.com> |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 3 | * |
Yang Ling | 5e73ad3 | 2016-12-04 23:05:40 +0800 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 7 | * option) any later version. |
| 8 | */ |
| 9 | |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 10 | #include <linux/leds.h> |
| 11 | #include <linux/mtd/partitions.h> |
| 12 | #include <linux/sizes.h> |
| 13 | |
| 14 | #include <loongson1.h> |
| 15 | #include <dma.h> |
| 16 | #include <nand.h> |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 17 | #include <platform.h> |
| 18 | |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 19 | struct plat_ls1x_dma ls1x_dma_pdata = { |
| 20 | .nr_channels = 3, |
| 21 | }; |
| 22 | |
| 23 | static struct mtd_partition ls1x_nand_parts[] = { |
| 24 | { |
| 25 | .name = "kernel", |
| 26 | .offset = 0, |
| 27 | .size = SZ_16M, |
| 28 | }, |
| 29 | { |
| 30 | .name = "rootfs", |
| 31 | .offset = MTDPART_OFS_APPEND, |
| 32 | .size = MTDPART_SIZ_FULL, |
| 33 | }, |
| 34 | }; |
| 35 | |
| 36 | struct plat_ls1x_nand ls1x_nand_pdata = { |
| 37 | .parts = ls1x_nand_parts, |
| 38 | .nr_parts = ARRAY_SIZE(ls1x_nand_parts), |
| 39 | .hold_cycle = 0x2, |
| 40 | .wait_cycle = 0xc, |
| 41 | }; |
| 42 | |
| 43 | static const struct gpio_led ls1x_gpio_leds[] __initconst = { |
| 44 | { |
| 45 | .name = "LED9", |
| 46 | .default_trigger = "heartbeat", |
| 47 | .gpio = 38, |
| 48 | .active_low = 1, |
| 49 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 50 | }, { |
| 51 | .name = "LED6", |
| 52 | .default_trigger = "nand-disk", |
| 53 | .gpio = 39, |
| 54 | .active_low = 1, |
| 55 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static const struct gpio_led_platform_data ls1x_led_pdata __initconst = { |
| 60 | .num_leds = ARRAY_SIZE(ls1x_gpio_leds), |
| 61 | .leds = ls1x_gpio_leds, |
| 62 | }; |
| 63 | |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 64 | static struct platform_device *ls1b_platform_devices[] __initdata = { |
Kelvin Cheung | f29ad10 | 2014-10-10 11:40:01 +0800 | [diff] [blame] | 65 | &ls1x_uart_pdev, |
| 66 | &ls1x_cpufreq_pdev, |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 67 | &ls1x_dma_pdev, |
Kelvin Cheung | f29ad10 | 2014-10-10 11:40:01 +0800 | [diff] [blame] | 68 | &ls1x_eth0_pdev, |
| 69 | &ls1x_eth1_pdev, |
| 70 | &ls1x_ehci_pdev, |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 71 | &ls1x_gpio0_pdev, |
| 72 | &ls1x_gpio1_pdev, |
| 73 | &ls1x_nand_pdev, |
Kelvin Cheung | f29ad10 | 2014-10-10 11:40:01 +0800 | [diff] [blame] | 74 | &ls1x_rtc_pdev, |
Yang Ling | 5e73ad3 | 2016-12-04 23:05:40 +0800 | [diff] [blame] | 75 | &ls1x_wdt_pdev, |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static int __init ls1b_platform_init(void) |
| 79 | { |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 80 | ls1x_serial_set_uartclk(&ls1x_uart_pdev); |
| 81 | ls1x_dma_set_platdata(&ls1x_dma_pdata); |
| 82 | ls1x_nand_set_platdata(&ls1x_nand_pdata); |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 83 | |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 84 | gpio_led_register_device(-1, &ls1x_led_pdata); |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 85 | |
Kelvin Cheung | 9ec88b6 | 2016-04-06 20:34:54 +0800 | [diff] [blame] | 86 | return platform_add_devices(ls1b_platform_devices, |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 87 | ARRAY_SIZE(ls1b_platform_devices)); |
Kelvin Cheung | ca585cf | 2012-07-25 16:17:24 +0200 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | arch_initcall(ls1b_platform_init); |