| 1 | --- a/arch/arm/mach-cns21xx/Kconfig |
| 2 | +++ b/arch/arm/mach-cns21xx/Kconfig |
| 3 | @@ -1,6 +1,16 @@ |
| 4 | if ARCH_CNS21XX |
| 5 | |
| 6 | menu "Cavium Networks CNS21xx based machines" |
| 7 | + |
| 8 | +config MACH_NS_K330 |
| 9 | + bool "NS-K330 NAS" |
| 10 | + select CNS21XX_DEV_GEC |
| 11 | + select CNS21XX_DEV_SPI_MASTER |
| 12 | + select CNS21XX_DEV_USB |
| 13 | + help |
| 14 | + Say Y here if you intend to run this kernel on the |
| 15 | + NS-K330 NAS board. |
| 16 | + |
| 17 | endmenu |
| 18 | |
| 19 | config CNS21XX_DEV_GEC |
| 20 | --- /dev/null |
| 21 | +++ b/arch/arm/mach-cns21xx/mach-ns-k330.c |
| 22 | @@ -0,0 +1,204 @@ |
| 23 | +/* |
| 24 | + * NS-K330 NAS board support |
| 25 | + * |
| 26 | + * Copyright (c) 2010-2012 Gabor Juhos <juhosg@openwrt.org> |
| 27 | + * |
| 28 | + * This file is free software; you can redistribute it and/or modify |
| 29 | + * it under the terms of the GNU General Public License, Version 2, as |
| 30 | + * published by the Free Software Foundation. |
| 31 | + */ |
| 32 | + |
| 33 | +#include <linux/kernel.h> |
| 34 | +#include <linux/init.h> |
| 35 | +#include <linux/mtd/mtd.h> |
| 36 | +#include <linux/mtd/map.h> |
| 37 | +#include <linux/mtd/partitions.h> |
| 38 | +#include <linux/spi/spi.h> |
| 39 | +#include <linux/spi/flash.h> |
| 40 | +#include <linux/platform_device.h> |
| 41 | +#include <linux/gpio.h> |
| 42 | +#include <linux/leds.h> |
| 43 | +#include <linux/gpio_keys.h> |
| 44 | +#include <linux/input.h> |
| 45 | + |
| 46 | +#include <asm/setup.h> |
| 47 | +#include <asm/mach-types.h> |
| 48 | +#include <asm/mach/arch.h> |
| 49 | +#include <asm/mach/time.h> |
| 50 | +#include <mach/hardware.h> |
| 51 | +#include <mach/cns21xx.h> |
| 52 | +#include <mach/cns21xx_misc.h> |
| 53 | + |
| 54 | +#include "common.h" |
| 55 | +#include "dev-gec.h" |
| 56 | + |
| 57 | +#define NS_K330_GPIO_LED_LINK 1 |
| 58 | +#define NS_K330_GPIO_LED_USB1 16 |
| 59 | +#define NS_K330_GPIO_LED_USB2 17 |
| 60 | +#define NS_K330_GPIO_LED_ETH_GREEN 22 |
| 61 | +#define NS_K330_GPIO_LED_ETH_ORANGE 23 |
| 62 | + |
| 63 | +#define NS_K330_GPIO_BTN_RESET 13 |
| 64 | +#define NS_K330_GPIO_BTN_USB1 14 |
| 65 | +#define NS_K330_GPIO_BTN_USB2 15 |
| 66 | + |
| 67 | +static struct mtd_partition ns_k330_partitions[] = { |
| 68 | + { |
| 69 | + .name = "boot", |
| 70 | + .offset = 0x0, |
| 71 | + .size = 0x040000, |
| 72 | + .mask_flags = MTD_WRITEABLE, |
| 73 | + }, { |
| 74 | + .name = "config", |
| 75 | + .offset = 0x040000, |
| 76 | + .size = 0x020000, |
| 77 | + .mask_flags = MTD_WRITEABLE, |
| 78 | + }, { |
| 79 | + .name = "kernel", |
| 80 | + .offset = 0x060000, |
| 81 | + .size = 0x100000, |
| 82 | + }, { |
| 83 | + .name = "rootfs", |
| 84 | + .offset = 0x160000, |
| 85 | + .size = 0x290000, |
| 86 | + }, { |
| 87 | + .name = "firmware", |
| 88 | + .offset = 0x060000, |
| 89 | + .size = 0x390000, |
| 90 | + }, |
| 91 | +}; |
| 92 | + |
| 93 | +static struct flash_platform_data ns_k330_flash_data = { |
| 94 | + .parts = ns_k330_partitions, |
| 95 | + .nr_parts = ARRAY_SIZE(ns_k330_partitions), |
| 96 | +}; |
| 97 | + |
| 98 | +static struct spi_board_info ns_k330_spi_board_info[] = { |
| 99 | + { |
| 100 | + .bus_num = 0, |
| 101 | + .chip_select = 0, |
| 102 | + .max_speed_hz = 25000000, |
| 103 | + .modalias = "m25p80", |
| 104 | + .platform_data = &ns_k330_flash_data, |
| 105 | + } |
| 106 | +}; |
| 107 | + |
| 108 | +static struct gpio_led ns_k330_gpio_leds[] = { |
| 109 | + { |
| 110 | + .name = "ns-k330:red:link", |
| 111 | + .gpio = NS_K330_GPIO_LED_LINK, |
| 112 | + .active_low = 1, |
| 113 | + }, { |
| 114 | + .name = "ns-k330:green:usb1", |
| 115 | + .gpio = NS_K330_GPIO_LED_USB1, |
| 116 | + .active_low = 1, |
| 117 | + }, { |
| 118 | + .name = "ns-k330:green:usb2", |
| 119 | + .gpio = NS_K330_GPIO_LED_USB2, |
| 120 | + .active_low = 1, |
| 121 | + }, { |
| 122 | + .name = "ns-k330:green:eth", |
| 123 | + .gpio = NS_K330_GPIO_LED_ETH_GREEN, |
| 124 | + .active_low = 1, |
| 125 | + }, { |
| 126 | + .name = "ns-k330:orange:eth", |
| 127 | + .gpio = NS_K330_GPIO_LED_ETH_ORANGE, |
| 128 | + .active_low = 1, |
| 129 | + } |
| 130 | +}; |
| 131 | + |
| 132 | +static struct gpio_led_platform_data ns_k330_gpio_leds_data = { |
| 133 | + .num_leds = ARRAY_SIZE(ns_k330_gpio_leds), |
| 134 | + .leds = ns_k330_gpio_leds, |
| 135 | +}; |
| 136 | + |
| 137 | +static struct platform_device ns_k330_gpio_leds_device = { |
| 138 | + .name = "leds-gpio", |
| 139 | + .id = -1, |
| 140 | + .dev.platform_data = &ns_k330_gpio_leds_data, |
| 141 | +}; |
| 142 | + |
| 143 | +static struct gpio_keys_button ns_k330_gpio_keys[] = { |
| 144 | + { |
| 145 | + .code = KEY_RESTART, |
| 146 | + .gpio = NS_K330_GPIO_BTN_RESET, |
| 147 | + .desc = "Reset Button", |
| 148 | + .active_low = 1, |
| 149 | + }, |
| 150 | + { |
| 151 | + .code = BTN_0, |
| 152 | + .gpio = NS_K330_GPIO_BTN_USB1, |
| 153 | + .desc = "USB1 Button", |
| 154 | + .active_low = 1, |
| 155 | + }, |
| 156 | + { |
| 157 | + .code = BTN_1, |
| 158 | + .gpio = NS_K330_GPIO_BTN_USB2, |
| 159 | + .desc = "USB2 Button", |
| 160 | + .active_low = 0, |
| 161 | + }, |
| 162 | +}; |
| 163 | + |
| 164 | +static struct gpio_keys_platform_data ns_k330_gpio_keys_data = { |
| 165 | + .buttons = ns_k330_gpio_keys, |
| 166 | + .nbuttons = ARRAY_SIZE(ns_k330_gpio_keys), |
| 167 | +}; |
| 168 | + |
| 169 | +static struct platform_device ns_k330_gpio_keys_device = { |
| 170 | + .name = "gpio-keys", |
| 171 | + .id = -1, |
| 172 | + .num_resources = 0, |
| 173 | + .dev = { |
| 174 | + .platform_data = &ns_k330_gpio_keys_data, |
| 175 | + }, |
| 176 | +}; |
| 177 | + |
| 178 | +static void __init ns_k330_fixup(struct tag *tags, char **cmdline, |
| 179 | + struct meminfo *mi) |
| 180 | +{ |
| 181 | + struct tag *t; |
| 182 | + |
| 183 | + /* The board has 32MB of RAM mapped at 0. */ |
| 184 | + mi->nr_banks = 1; |
| 185 | + mi->bank[0].start = 0; |
| 186 | + mi->bank[0].size = SZ_32M; |
| 187 | + |
| 188 | + for (t = tags; t->hdr.size; t = tag_next(t)) { |
| 189 | + switch (t->hdr.tag) { |
| 190 | + case ATAG_CORE: |
| 191 | + if (t->u.core.rootdev == 255) |
| 192 | + t->u.core.rootdev = 0; |
| 193 | + break; |
| 194 | + } |
| 195 | + } |
| 196 | +} |
| 197 | + |
| 198 | +static void __init ns_k330_init(void) |
| 199 | +{ |
| 200 | + cns21xx_gpio_init(); |
| 201 | + |
| 202 | + HAL_MISC_DISABLE_LED012_PINS(); |
| 203 | + HAL_MISC_DISABLE_I2C_PINS(); |
| 204 | + HAL_MISC_DISABLE_I2S_PINS(); |
| 205 | + |
| 206 | + cns21xx_register_uart0(); |
| 207 | + cns21xx_register_wdt(); |
| 208 | + cns21xx_register_usb(); |
| 209 | + cns21xx_register_spi_master(-1, ns_k330_spi_board_info, |
| 210 | + ARRAY_SIZE(ns_k330_spi_board_info)); |
| 211 | + |
| 212 | + cns21xx_gec_data.phy_type = CNS21XX_GEC_PHY_TYPE_INTERNAL; |
| 213 | + cns21xx_register_gec(); |
| 214 | + |
| 215 | + platform_device_register(&ns_k330_gpio_leds_device); |
| 216 | + platform_device_register(&ns_k330_gpio_keys_device); |
| 217 | +} |
| 218 | + |
| 219 | +MACHINE_START(NS_K330, "NS-K330 NAS") |
| 220 | + .fixup = ns_k330_fixup, |
| 221 | + .map_io = cns21xx_map_io, |
| 222 | + .init_irq = cns21xx_init_irq, |
| 223 | + .timer = &cns21xx_timer, |
| 224 | + .init_machine = ns_k330_init, |
| 225 | + .restart = cns21xx_restart, |
| 226 | +MACHINE_END |
| 227 | --- a/arch/arm/mach-cns21xx/Makefile |
| 228 | +++ b/arch/arm/mach-cns21xx/Makefile |
| 229 | @@ -12,4 +12,4 @@ obj-$(CONFIG_CNS21XX_DEV_USB) += dev-us |
| 230 | obj-$(CONFIG_CNS21XX_DEV_SPI_MASTER) += dev-spi-master.o |
| 231 | |
| 232 | # machine specific files |
| 233 | - |
| 234 | +obj-$(CONFIG_MACH_NS_K330) += mach-ns-k330.o |
| 235 | |