17 #include <linux/kernel.h>
21 #include <linux/pci.h>
27 #include <linux/input.h>
28 #include <linux/i2c.h>
42 #define DNS323_GPIO_LED_RIGHT_AMBER 1
43 #define DNS323_GPIO_LED_LEFT_AMBER 2
44 #define DNS323_GPIO_SYSTEM_UP 3
45 #define DNS323_GPIO_LED_POWER1 4
46 #define DNS323_GPIO_LED_POWER2 5
47 #define DNS323_GPIO_OVERTEMP 6
48 #define DNS323_GPIO_RTC 7
49 #define DNS323_GPIO_POWER_OFF 8
50 #define DNS323_GPIO_KEY_POWER 9
51 #define DNS323_GPIO_KEY_RESET 10
54 #define DNS323C_GPIO_KEY_POWER 1
55 #define DNS323C_GPIO_POWER_OFF 2
56 #define DNS323C_GPIO_LED_RIGHT_AMBER 8
57 #define DNS323C_GPIO_LED_LEFT_AMBER 9
58 #define DNS323C_GPIO_LED_POWER 17
59 #define DNS323C_GPIO_FAN_BIT1 18
60 #define DNS323C_GPIO_FAN_BIT0 19
92 .map_irq = dns323_pci_map_irq,
95 static int __init dns323_pci_init(
void)
119 #define DNS323_NOR_BOOT_BASE 0xf4000000
120 #define DNS323_NOR_BOOT_SIZE SZ_8M
130 .offset = 0x00010000,
132 .name =
"Linux Kernel",
134 .offset = 0x00020000,
136 .name =
"File System",
138 .offset = 0x001A0000,
142 .offset = 0x007d0000,
148 .parts = dns323_partitions,
152 static struct resource dns323_nor_flash_resource = {
159 .name =
"physmap-flash",
162 .platform_data = &dns323_nor_flash_data,
164 .resource = &dns323_nor_flash_resource,
179 static int __init dns323_parse_hex_nibble(
char n)
181 if (n >=
'0' && n <=
'9')
184 if (n >=
'A' && n <=
'F')
187 if (n >=
'a' && n <=
'f')
193 static int __init dns323_parse_hex_byte(
const char *
b)
198 hi = dns323_parse_hex_nibble(b[0]);
199 lo = dns323_parse_hex_nibble(b[1]);
201 if (hi < 0 || lo < 0)
204 return (hi << 4) | lo;
207 static int __init dns323_read_mac_addr(
void)
221 for (i = 0; i < 5; i++) {
222 if (*(mac_page + (i * 3) + 2) !=
':') {
227 for (i = 0; i < 6; i++) {
230 byte = dns323_parse_hex_byte(mac_page + (i * 3));
239 printk(
"DNS-323: Found ethernet MAC address: ");
240 for (i = 0; i < 6; i++)
241 printk(
"%.2x%s", addr[i], (i < 5) ?
":" :
".\n");
256 static struct gpio_led dns323ab_leds[] = {
258 .name =
"power:blue",
260 .default_trigger =
"default-on",
262 .name =
"right:amber",
266 .name =
"left:amber",
273 static struct gpio_led dns323c_leds[] = {
275 .name =
"power:blue",
277 .default_trigger =
"timer",
280 .name =
"right:amber",
284 .name =
"left:amber",
293 .leds = dns323ab_leds,
299 .leds = dns323c_leds,
307 .platform_data = &dns323ab_led_data,
319 .desc =
"Reset Button",
324 .desc =
"Power Button",
330 .buttons = dns323ab_buttons,
338 .desc =
"Power Button",
344 .buttons = dns323c_buttons,
353 .platform_data = &dns323ab_button_data,
367 static unsigned int dns323a_mpp_modes[] __initdata = {
391 static unsigned int dns323b_mpp_modes[] __initdata = {
415 static unsigned int dns323c_mpp_modes[] __initdata = {
465 static struct i2c_board_info __initdata dns323ab_i2c_devices[] = {
491 static void dns323a_power_off(
void)
493 pr_info(
"DNS-323: Triggering power-off...\n");
498 static void dns323b_power_off(
void)
500 pr_info(
"DNS-323: Triggering power-off...\n");
508 static void dns323c_power_off(
void)
510 pr_info(
"DNS-323: Triggering power-off...\n");
521 static int __init dns323_identify_rev(
void)
525 pr_debug(
"DNS-323: Identifying board ... \n");
530 pr_debug(
"DNS-323: 5181 found, board is A1\n");
533 pr_debug(
"DNS-323: 5182 found, board is B1 or C1, checking PHY...\n");
541 #define ETH_SMI_REG (ORION5X_ETH_VIRT_BASE + 0x2000 + 0x004)
542 #define SMI_BUSY 0x10000000
543 #define SMI_READ_VALID 0x08000000
544 #define SMI_OPCODE_READ 0x04000000
545 #define SMI_OPCODE_WRITE 0x00000000
547 for (i = 0; i < 1000; i++) {
548 reg =
readl(ETH_SMI_REG);
549 if (!(reg & SMI_BUSY))
553 pr_warning(
"DNS-323: Timeout accessing PHY, assuming rev B1\n");
558 SMI_OPCODE_READ, ETH_SMI_REG);
559 for (i = 0; i < 1000; i++) {
560 reg =
readl(ETH_SMI_REG);
561 if (reg & SMI_READ_VALID)
565 pr_warning(
"DNS-323: Timeout reading PHY, assuming rev B1\n");
568 pr_debug(
"DNS-323: Ethernet PHY ID 0x%x\n", reg & 0xffff);
574 switch(reg & 0xfff0) {
580 pr_warning(
"DNS-323: Unknown PHY ID 0x%04x, assuming rev B1\n",
586 static void __init dns323_init(
void)
633 dns323_gpio_leds.
dev.platform_data = &dns323c_led_data;
634 dns323_button_device.
dev.platform_data = &dns323c_button_data;
639 platform_device_register_simple(
"dns323c-fan", 0,
NULL, 0);
653 if (dns323_read_mac_addr() < 0)
654 printk(
"DNS-323: Failed to read MAC address\n");
666 pr_err(
"DNS-323: failed to setup power-off GPIO\n");
683 pr_err(
"DNS-323: failed to setup power-off GPIO\n");
693 pr_err(
"DNS-323: failed to setup power-off GPIO\n");
712 .atag_offset = 0x100,
713 .init_machine = dns323_init,