#include <asm/irq.h>
#include <asm/io.h>
#include <ar531x.h>
+#include <linux/leds.h>
+#include <asm/gpio.h>
static int is_5315 = 0;
.num_resources = ARRAY_SIZE(ar5315_spiflash_res)
};
-static __initdata struct platform_device *ar5315_devs[4];
+#ifdef CONFIG_LEDS_GPIO
+static struct gpio_led ar5315_leds[8];
+static struct gpio_led_platform_data ar5315_led_data = {
+ .num_leds = ARRAY_SIZE(ar5315_leds),
+ .leds = (void *) ar5315_leds,
+};
+static struct platform_device ar5315_gpio_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = (void *) &ar5315_led_data,
+ }
+};
+#endif
+
+static struct platform_device ar5315_wdt =
+{
+ .id = 0,
+ .name = "ar2315_wdt",
+};
+
+static __initdata struct platform_device *ar5315_devs[6];
static void *flash_regs;
spiflash_regwrite32(SPI_FLASH_OPCODE, 0xab);
reg = (reg & ~SPI_CTL_TX_RX_CNT_MASK) | 4 |
- (1 << 4) | SPI_CTL_START;
+ (1 << 4) | SPI_CTL_START;
spiflash_regwrite32(SPI_FLASH_CTL, reg);
-
+
do {
- reg = spiflash_regread32(SPI_FLASH_CTL);
+ reg = spiflash_regread32(SPI_FLASH_CTL);
} while (reg & SPI_CTL_BUSY);
reg = (__u32) spiflash_regread32(SPI_FLASH_DATA);
struct ar531x_config *config;
struct ar531x_boarddata *bcfg;
int dev = 0;
+#ifdef CONFIG_LEDS_GPIO
+ int i;
+ char *tmp;
+#endif
if (!is_5315)
return 0;
config->radio = radio_config;
config->unit = 0;
config->tag = (u_int16_t) (sysRegRead(AR5315_SREV) & AR5315_REV_CHIP);
-
+
ar5315_eth_data.board_config = board_config;
ar5315_eth_data.macaddr = bcfg->enet0Mac;
ar5315_wmac.dev.platform_data = config;
-
+
ar5315_devs[dev++] = &ar5315_eth;
ar5315_devs[dev++] = &ar5315_wmac;
ar5315_devs[dev++] = &ar5315_spiflash;
-
+ ar5315_devs[dev++] = &ar5315_wdt;
+
+#ifdef CONFIG_LEDS_GPIO
+ ar5315_led_data.num_leds = 0;
+ for(i = 0; i < 8; i++)
+ {
+ if((i != AR5315_RESET_GPIO) && (i != bcfg->resetConfigGpio))
+ {
+ if(i == bcfg->sysLedGpio)
+ {
+ tmp = kstrdup("wlan", GFP_KERNEL);
+ } else {
+ tmp = kmalloc(6, GFP_KERNEL);
+ if(tmp)
+ sprintf((char*)tmp, "gpio%d", i);
+ }
+ if(tmp)
+ {
+ ar5315_leds[ar5315_led_data.num_leds].name = tmp;
+ ar5315_leds[ar5315_led_data.num_leds].gpio = i;
+ ar5315_leds[ar5315_led_data.num_leds].active_low = 0;
+ ar5315_led_data.num_leds++;
+ } else {
+ printk("failed to alloc led string\n");
+ continue;
+ }
+ }
+ }
+ ar5315_devs[dev++] = &ar5315_gpio_leds;
+#endif
return platform_add_devices(ar5315_devs, dev);
}
{
unsigned int reg;
for(;;) {
-
/* reset the system */
sysRegWrite(AR5315_COLD_RESET,AR5317_RESET_SYSTEM);
- /*
+ /*
* Cold reset does not work on the AR2315/6, use the GPIO reset bits a workaround.
*/
-
- reg = sysRegRead(AR5315_GPIO_DO);
- reg &= ~(1 << AR5315_RESET_GPIO);
- sysRegWrite(AR5315_GPIO_DO, reg);
- (void)sysRegRead(AR5315_GPIO_DO); /* flush write to hardware */
+ gpio_direction_output(AR5315_RESET_GPIO, 0);
}
}
clkDiv = 1;
break;
}
- cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
+ cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
cpuDiv = cpuDiv * 2 ?: 1;
return (pllcOut/(clkDiv * cpuDiv));
}
-
+
static inline unsigned int ar5315_cpu_frequency(void)
{
return ar5315_sys_clk(sysRegRead(AR5315_CPUCLK));