Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * arch/arm/mach-orion5x/dns323-setup.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Support for HW Rev C1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2010 Benjamin Herrenschmidt <benh@kernel.crashing.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * it under the terms of the GNU Lesser General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * published by the Free Software Foundation; either version 2 of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/mtd/physmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/mv643xx_eth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/ata_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/marvell_phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <asm/mach/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <asm/system_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <plat/orion-gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include "orion5x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include "mpp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* Rev A1 and B1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define DNS323_GPIO_LED_RIGHT_AMBER	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define DNS323_GPIO_LED_LEFT_AMBER	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define DNS323_GPIO_SYSTEM_UP		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define DNS323_GPIO_LED_POWER1		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define DNS323_GPIO_LED_POWER2		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define DNS323_GPIO_OVERTEMP		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define DNS323_GPIO_RTC			7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define DNS323_GPIO_POWER_OFF		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define DNS323_GPIO_KEY_POWER		9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define DNS323_GPIO_KEY_RESET		10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /* Rev C1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define DNS323C_GPIO_KEY_POWER		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define DNS323C_GPIO_POWER_OFF		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define DNS323C_GPIO_LED_RIGHT_AMBER	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define DNS323C_GPIO_LED_LEFT_AMBER	9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define DNS323C_GPIO_LED_POWER		17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define DNS323C_GPIO_FAN_BIT1		18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define DNS323C_GPIO_FAN_BIT0		19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* Exposed to userspace, do not change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	DNS323_REV_A1,	/* 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	DNS323_REV_B1,	/* 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	DNS323_REV_C1,	/* 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * PCI setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static int __init dns323_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * Check for devices with hard-wired IRQs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	irq = orion5x_pci_map_irq(dev, slot, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	if (irq != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static struct hw_pci dns323_pci __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	.nr_controllers = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	.setup		= orion5x_pci_sys_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	.scan		= orion5x_pci_sys_scan_bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	.map_irq	= dns323_pci_map_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static int __init dns323_pci_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* Rev B1 and C1 doesn't really use its PCI bus, and initialising PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * gets in the way of initialising the SATA controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (machine_is_dns323() && system_rev == DNS323_REV_A1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		pci_common_init(&dns323_pci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) subsys_initcall(dns323_pci_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * Layout as used by D-Link:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *  0x00000000-0x00010000 : "MTD1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *  0x00010000-0x00020000 : "MTD2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *  0x00020000-0x001a0000 : "Linux Kernel"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *  0x001a0000-0x007d0000 : "File System"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *  0x007d0000-0x00800000 : "u-boot"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define DNS323_NOR_BOOT_BASE 0xf4000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define DNS323_NOR_BOOT_SIZE SZ_8M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static struct mtd_partition dns323_partitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		.name	= "MTD1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		.size	= 0x00010000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		.offset	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		.name	= "MTD2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.size	= 0x00010000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.offset = 0x00010000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		.name	= "Linux Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		.size	= 0x00180000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		.offset	= 0x00020000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.name	= "File System",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.size	= 0x00630000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.offset	= 0x001A0000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.name	= "u-boot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		.size	= 0x00030000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		.offset	= 0x007d0000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static struct physmap_flash_data dns323_nor_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	.width		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	.parts		= dns323_partitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	.nr_parts	= ARRAY_SIZE(dns323_partitions)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static struct resource dns323_nor_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	.flags		= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	.start		= DNS323_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	.end		= DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static struct platform_device dns323_nor_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.name		= "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.id		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		.platform_data	= &dns323_nor_flash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.resource	= &dns323_nor_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	.num_resources	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * Ethernet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static struct mv643xx_eth_platform_data dns323_eth_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.phy_addr = MV643XX_ETH_PHY_ADDR(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* dns323_parse_hex_*() taken from tsx09-common.c; should a common copy of these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * functions be kept somewhere?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static int __init dns323_parse_hex_nibble(char n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (n >= '0' && n <= '9')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		return n - '0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (n >= 'A' && n <= 'F')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return n - 'A' + 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (n >= 'a' && n <= 'f')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return n - 'a' + 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int __init dns323_parse_hex_byte(const char *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	int hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	hi = dns323_parse_hex_nibble(b[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	lo = dns323_parse_hex_nibble(b[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (hi < 0 || lo < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	return (hi << 4) | lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) static int __init dns323_read_mac_addr(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	u_int8_t addr[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	char *mac_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	/* MAC address is stored as a regular ol' string in /dev/mtdblock4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 * (0x007d0000-0x00800000) starting at offset 196480 (0x2ff80).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (!mac_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	/* Sanity check the string we're looking at */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	for (i = 0; i < 5; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		if (*(mac_page + (i * 3) + 2) != ':') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			goto error_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	for (i = 0; i < 6; i++)	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		int byte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		byte = dns323_parse_hex_byte(mac_page + (i * 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		if (byte < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			goto error_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		addr[i] = byte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	iounmap(mac_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	printk("DNS-323: Found ethernet MAC address: %pM\n", addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	memcpy(dns323_eth_data.mac_addr, addr, 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) error_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	iounmap(mac_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * GPIO LEDs (simple - doesn't use hardware blinking support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static struct gpio_led dns323ab_leds[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		.name = "power:blue",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		.gpio = DNS323_GPIO_LED_POWER2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		.default_trigger = "default-on",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		.name = "right:amber",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		.gpio = DNS323_GPIO_LED_RIGHT_AMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		.active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		.name = "left:amber",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		.gpio = DNS323_GPIO_LED_LEFT_AMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		.active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static struct gpio_led dns323c_leds[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		.name = "power:blue",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		.gpio = DNS323C_GPIO_LED_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		.default_trigger = "timer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		.active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		.name = "right:amber",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		.gpio = DNS323C_GPIO_LED_RIGHT_AMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		.active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		.name = "left:amber",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		.gpio = DNS323C_GPIO_LED_LEFT_AMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		.active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static struct gpio_led_platform_data dns323ab_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	.num_leds	= ARRAY_SIZE(dns323ab_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	.leds		= dns323ab_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	.gpio_blink_set = orion_gpio_led_blink_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static struct gpio_led_platform_data dns323c_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	.num_leds	= ARRAY_SIZE(dns323c_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	.leds		= dns323c_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	.gpio_blink_set = orion_gpio_led_blink_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static struct platform_device dns323_gpio_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	.name		= "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		.platform_data	= &dns323ab_led_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * GPIO Attached Keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static struct gpio_keys_button dns323ab_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		.code		= KEY_RESTART,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		.gpio		= DNS323_GPIO_KEY_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		.desc		= "Reset Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		.code		= KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		.gpio		= DNS323_GPIO_KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		.desc		= "Power Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static struct gpio_keys_platform_data dns323ab_button_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	.buttons	= dns323ab_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	.nbuttons	= ARRAY_SIZE(dns323ab_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static struct gpio_keys_button dns323c_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		.code		= KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		.gpio		= DNS323C_GPIO_KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		.desc		= "Power Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static struct gpio_keys_platform_data dns323c_button_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	.buttons	= dns323c_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	.nbuttons	= ARRAY_SIZE(dns323c_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static struct platform_device dns323_button_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	.name		= "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	.num_resources	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		.platform_data	= &dns323ab_button_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  * SATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static struct mv_sata_platform_data dns323_sata_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)        .n_ports        = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  * General Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) static unsigned int dns323a_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	MPP0_PCIE_RST_OUTn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	MPP1_GPIO,		/* right amber LED (sata ch0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	MPP2_GPIO,		/* left amber LED (sata ch1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	MPP3_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	MPP4_GPIO,		/* power button LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	MPP5_GPIO,		/* power button LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	MPP6_GPIO,		/* GMT G751-2f overtemp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	MPP7_GPIO,		/* M41T80 nIRQ/OUT/SQW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	MPP8_GPIO,		/* triggers power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	MPP9_GPIO,		/* power button switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	MPP10_GPIO,		/* reset button switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	MPP11_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	MPP12_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	MPP13_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	MPP14_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	MPP15_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	MPP16_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	MPP17_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	MPP18_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	MPP19_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static unsigned int dns323b_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	MPP0_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	MPP1_GPIO,		/* right amber LED (sata ch0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	MPP2_GPIO,		/* left amber LED (sata ch1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	MPP3_GPIO,		/* system up flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	MPP4_GPIO,		/* power button LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	MPP5_GPIO,		/* power button LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	MPP6_GPIO,		/* GMT G751-2f overtemp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	MPP7_GPIO,		/* M41T80 nIRQ/OUT/SQW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	MPP8_GPIO,		/* triggers power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	MPP9_GPIO,		/* power button switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	MPP10_GPIO,		/* reset button switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	MPP11_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	MPP12_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	MPP13_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	MPP14_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	MPP15_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	MPP16_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	MPP17_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	MPP18_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	MPP19_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static unsigned int dns323c_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	MPP0_GPIO,		/* ? input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	MPP1_GPIO,		/* input power switch (0 = pressed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	MPP2_GPIO,		/* output power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	MPP3_UNUSED,		/* ? output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	MPP4_UNUSED,		/* ? output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	MPP5_UNUSED,		/* ? output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	MPP6_UNUSED,		/* ? output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	MPP7_UNUSED,		/* ? output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	MPP8_GPIO,		/* i/o right amber LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	MPP9_GPIO,		/* i/o left amber LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	MPP10_GPIO,		/* input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	MPP11_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	MPP12_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	MPP13_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	MPP14_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	MPP15_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	MPP16_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	MPP17_GPIO,		/* power button LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	MPP18_GPIO,		/* fan speed bit 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	MPP19_GPIO,		/* fan speed bit 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) /* Rev C1 Fan speed notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  * The fan is controlled by 2 GPIOs on this board. The settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  * of the bits is as follow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  *  GPIO 18    GPIO 19    Fan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  *    0          0        stopped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  *    0          1        low speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  *    1          0        high speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  *    1          1        don't do that (*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)  * (*) I think the two bits control two feed-in resistors into a fixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)  *     PWN circuit, setting both bits will basically go a 'bit' faster
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)  *     than high speed, but d-link doesn't do it and you may get out of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)  *     HW spec so don't do it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  * On the DNS-323 A1 and B1 the following devices are attached via I2C:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  *  i2c addr | chip        | description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)  *  0x3e     | GMT G760Af  | fan speed PWM controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)  *  0x48     | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  *  0x68     | ST M41T80   | RTC w/ alarm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) static struct i2c_board_info __initdata dns323ab_i2c_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		I2C_BOARD_INFO("g760a", 0x3e),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		I2C_BOARD_INFO("lm75", 0x48),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		I2C_BOARD_INFO("m41t80", 0x68),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)  * On the DNS-323 C1 the following devices are attached via I2C:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  *  i2c addr | chip        | description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  *  0x48     | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  *  0x68     | ST M41T80   | RTC w/ alarm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) static struct i2c_board_info __initdata dns323c_i2c_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		I2C_BOARD_INFO("lm75", 0x48),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		I2C_BOARD_INFO("m41t80", 0x68),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) /* DNS-323 rev. A specific power off method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static void dns323a_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	pr_info("DNS-323: Triggering power-off...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) /* DNS-323 rev B specific power off method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) static void dns323b_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	pr_info("DNS-323: Triggering power-off...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	/* Pin has to be changed to 1 and back to 0 to do actual power off. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	mdelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	gpio_set_value(DNS323_GPIO_POWER_OFF, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* DNS-323 rev. C specific power off method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static void dns323c_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	pr_info("DNS-323: Triggering power-off...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	gpio_set_value(DNS323C_GPIO_POWER_OFF, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) static int dns323c_phy_fixup(struct phy_device *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	phy->dev_flags |= MARVELL_PHY_M1118_DNS323_LEDS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) static int __init dns323_identify_rev(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	u32 dev, rev, i, reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	pr_debug("DNS-323: Identifying board ... \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	/* Rev A1 has a 5181 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	orion5x_pcie_id(&dev, &rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	if (dev == MV88F5181_DEV_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		pr_debug("DNS-323: 5181 found, board is A1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		return DNS323_REV_A1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	pr_debug("DNS-323: 5182 found, board is B1 or C1, checking PHY...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	/* Rev B1 and C1 both have 5182, let's poke at the eth PHY. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	 * a bit gross but we want to do that without links into the eth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	 * driver so let's poke at it directly. We default to rev B1 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	 * case the accesses fail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) #define ETH_SMI_REG		(ORION5X_ETH_VIRT_BASE + 0x2000 + 0x004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) #define  SMI_BUSY		0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) #define  SMI_READ_VALID		0x08000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) #define  SMI_OPCODE_READ	0x04000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) #define  SMI_OPCODE_WRITE	0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	for (i = 0; i < 1000; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		reg = readl(ETH_SMI_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		if (!(reg & SMI_BUSY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	if (i >= 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 		pr_warn("DNS-323: Timeout accessing PHY, assuming rev B1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 		return DNS323_REV_B1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	writel((3 << 21)	/* phy ID reg */ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	       (8 << 16)	/* phy addr */ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	       SMI_OPCODE_READ, ETH_SMI_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	for (i = 0; i < 1000; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		reg = readl(ETH_SMI_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		if (reg & SMI_READ_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	if (i >= 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		pr_warn("DNS-323: Timeout reading PHY, assuming rev B1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		return DNS323_REV_B1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	pr_debug("DNS-323: Ethernet PHY ID 0x%x\n", reg & 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	/* Note: the Marvell tools mask the ID with 0x3f0 before comparison
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	 * but I don't see that making a difference here, at least with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	 * any known Marvell PHY ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	switch(reg & 0xfff0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	case 0x0cc0: /* MV88E1111 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		return DNS323_REV_B1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	case 0x0e10: /* MV88E1118 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		return DNS323_REV_C1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 		pr_warn("DNS-323: Unknown PHY ID 0x%04x, assuming rev B1\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 			reg & 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	return DNS323_REV_B1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) static void __init dns323_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	/* Setup basic Orion functions. Need to be called early. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	orion5x_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	/* Identify revision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	system_rev = dns323_identify_rev();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	pr_info("DNS-323: Identified HW revision %c1\n", 'A' + system_rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	/* Just to be tricky, the 5182 has a completely different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	 * set of MPP modes to the 5181.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	switch(system_rev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	case DNS323_REV_A1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 		orion5x_mpp_conf(dns323a_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 		writel(0, MPP_DEV_CTRL);		/* DEV_D[31:16] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	case DNS323_REV_B1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		orion5x_mpp_conf(dns323b_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	case DNS323_REV_C1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 		orion5x_mpp_conf(dns323c_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	/* setup flash mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 				    ORION_MBUS_DEVBUS_BOOT_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 				    DNS323_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 				    DNS323_NOR_BOOT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	platform_device_register(&dns323_nor_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	/* Sort out LEDs, Buttons and i2c devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	switch(system_rev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	case DNS323_REV_A1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		/* The 5181 power LED is active low and requires
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		 * DNS323_GPIO_LED_POWER1 to also be low.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		 dns323ab_leds[0].active_low = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		 gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		 gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	case DNS323_REV_B1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		i2c_register_board_info(0, dns323ab_i2c_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 				ARRAY_SIZE(dns323ab_i2c_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	case DNS323_REV_C1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		/* Hookup LEDs & Buttons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 		dns323_gpio_leds.dev.platform_data = &dns323c_led_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		dns323_button_device.dev.platform_data = &dns323c_button_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		/* Hookup i2c devices and fan driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		i2c_register_board_info(0, dns323c_i2c_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 				ARRAY_SIZE(dns323c_i2c_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 		platform_device_register_simple("dns323c-fan", 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 		/* Register fixup for the PHY LEDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 		if (!IS_BUILTIN(CONFIG_PHYLIB))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		phy_register_fixup_for_uid(MARVELL_PHY_ID_88E1118,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 					   MARVELL_PHY_ID_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 					   dns323c_phy_fixup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	platform_device_register(&dns323_gpio_leds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	platform_device_register(&dns323_button_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	 * Configure peripherals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	if (dns323_read_mac_addr() < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		printk("DNS-323: Failed to read MAC address\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	orion5x_ehci0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	orion5x_eth_init(&dns323_eth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	orion5x_i2c_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	orion5x_uart0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	/* Remaining GPIOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	switch(system_rev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	case DNS323_REV_A1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		/* Poweroff GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 		    gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 			pr_err("DNS-323: failed to setup power-off GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		pm_power_off = dns323a_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	case DNS323_REV_B1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		/* 5182 built-in SATA init */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		orion5x_sata_init(&dns323_sata_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		/* The DNS323 rev B1 has flag to indicate the system is up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		 * Without this flag set, power LED will flash and cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		 * controlled via leds-gpio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		if (gpio_request(DNS323_GPIO_SYSTEM_UP, "SYS_READY") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 			gpio_direction_output(DNS323_GPIO_SYSTEM_UP, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		/* Poweroff GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 		    gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 			pr_err("DNS-323: failed to setup power-off GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 		pm_power_off = dns323b_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	case DNS323_REV_C1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 		/* 5182 built-in SATA init */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 		orion5x_sata_init(&dns323_sata_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 		/* Poweroff GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 		if (gpio_request(DNS323C_GPIO_POWER_OFF, "POWEROFF") != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 		    gpio_direction_output(DNS323C_GPIO_POWER_OFF, 0) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 			pr_err("DNS-323: failed to setup power-off GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 		pm_power_off = dns323c_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 		/* Now, -this- should theorically be done by the sata_mv driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		 * once I figure out what's going on there. Maybe the behaviour
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 		 * of the LEDs should be somewhat passed via the platform_data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 		 * for now, just whack the register and make the LEDs happy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		 * Note: AFAIK, rev B1 needs the same treatement but I'll let
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 		 * somebody else test it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 		writel(0x5, ORION5X_SATA_VIRT_BASE + 0x2c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) MACHINE_START(DNS323, "D-Link DNS-323")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	/* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	.nr_irqs	= ORION5X_NR_IRQS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	.init_machine	= dns323_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	.map_io		= orion5x_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	.init_early	= orion5x_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	.init_irq	= orion5x_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	.init_time	= orion5x_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	.fixup		= tag_fixup_mem32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	.restart	= orion5x_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) MACHINE_END