/* dns323_parse_hex_*() taken from tsx09-common.c; should a common copy of these *functionsbekeptsomewhere?
*/ staticint __init dns323_parse_hex_nibble(char n)
{ if (n >= '0' && n <= '9') return n - '0';
if (n >= 'A' && n <= 'F') return n - 'A' + 10;
if (n >= 'a' && n <= 'f') return n - 'a' + 10;
return -1;
}
staticint __init dns323_parse_hex_byte(constchar *b)
{ int hi; int lo;
hi = dns323_parse_hex_nibble(b[0]);
lo = dns323_parse_hex_nibble(b[1]);
if (hi < 0 || lo < 0) return -1;
return (hi << 4) | lo;
}
staticint __init dns323_read_mac_addr(void)
{
u_int8_t addr[6]; int i; char *mac_page;
/* MAC address is stored as a regular ol' string in /dev/mtdblock4 *(0x007d0000-0x00800000)startingatoffset196480(0x2ff80).
*/
mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024); if (!mac_page) return -ENOMEM;
/* Sanity check the string we're looking at */ for (i = 0; i < 5; i++) { if (*(mac_page + (i * 3) + 2) != ':') { goto error_fail;
}
}
for (i = 0; i < 6; i++) { int byte;
byte = dns323_parse_hex_byte(mac_page + (i * 3)); if (byte < 0) { goto error_fail;
}
addr[i] = byte;
}
iounmap(mac_page);
printk("DNS-323: Found ethernet MAC address: %pM\n", addr);
/* B1 is the same but power LED is active high */ staticstruct gpiod_lookup_table dns323b1_leds_gpio_table = {
.dev_id = "leds-gpio",
.table = {
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL, 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL, 1, GPIO_ACTIVE_LOW),
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL, 2, GPIO_ACTIVE_LOW),
{ },
},
};
/* DNS-323 rev. A specific power off method */ staticvoid dns323a_power_off(void)
{
pr_info("DNS-323: Triggering power-off...\n");
gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
}
/* DNS-323 rev B specific power off method */ staticvoid dns323b_power_off(void)
{
pr_info("DNS-323: Triggering power-off...\n"); /* Pin has to be changed to 1 and back to 0 to do actual power off. */
gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
mdelay(100);
gpio_set_value(DNS323_GPIO_POWER_OFF, 0);
}
/* DNS-323 rev. C specific power off method */ staticvoid dns323c_power_off(void)
{
pr_info("DNS-323: Triggering power-off...\n");
gpio_set_value(DNS323C_GPIO_POWER_OFF, 1);
}
staticint __init dns323_identify_rev(void)
{
u32 dev, rev, i, reg;
pr_debug("DNS-323: Identifying board ... \n");
/* Rev A1 has a 5181 */
orion5x_pcie_id(&dev, &rev); if (dev == MV88F5181_DEV_ID) {
pr_debug("DNS-323: 5181 found, board is A1\n"); return DNS323_REV_A1;
}
pr_debug("DNS-323: 5182 found, board is B1 or C1, checking PHY...\n");
/* Rev B1 and C1 both have 5182, let's poke at the eth PHY. This is *abitgrossbutwewanttodothatwithoutlinksintotheeth *driversolet'spokeatitdirectly.WedefaulttorevB1in *casetheaccessesfail
*/
/* Just to be tricky, the 5182 has a completely different *setofMPPmodestothe5181.
*/ switch(system_rev) { case DNS323_REV_A1:
orion5x_mpp_conf(dns323a_mpp_modes);
writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ break; case DNS323_REV_B1:
orion5x_mpp_conf(dns323b_mpp_modes); break; case DNS323_REV_C1:
orion5x_mpp_conf(dns323c_mpp_modes); break;
}
/* Sort out LEDs, Buttons and i2c devices */ switch(system_rev) { case DNS323_REV_A1: /* The 5181 power LED is active low and requires *DNS323_GPIO_LED_POWER1toalsobelow.
*/
gpiod_add_lookup_table(&dns323a1_leds_gpio_table);
gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
i2c_register_board_info(0, dns323ab_i2c_devices,
ARRAY_SIZE(dns323ab_i2c_devices));
/* Hookup i2c devices and fan driver */
i2c_register_board_info(0, dns323c_i2c_devices,
ARRAY_SIZE(dns323c_i2c_devices));
platform_device_register_simple("dns323c-fan", 0, NULL, 0);
/* Register fixup for the PHY LEDs */ if (!IS_BUILTIN(CONFIG_PHYLIB)) break;
phy_register_fixup_for_uid(MARVELL_PHY_ID_88E1118,
MARVELL_PHY_ID_MASK,
dns323c_phy_fixup);
}
/* *Configureperipherals.
*/ if (dns323_read_mac_addr() < 0)
printk("DNS-323: Failed to read MAC address\n");
orion5x_ehci0_init();
orion5x_eth_init(&dns323_eth_data);
orion5x_i2c_init();
orion5x_uart0_init();
/* Remaining GPIOs */ switch(system_rev) { case DNS323_REV_A1: /* Poweroff GPIO */ if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
pr_err("DNS-323: failed to setup power-off GPIO\n");
register_platform_power_off(dns323a_power_off); break; case DNS323_REV_B1: /* 5182 built-in SATA init */
orion5x_sata_init(&dns323_sata_data);
/* The DNS323 rev B1 has flag to indicate the system is up. *Withoutthisflagset,powerLEDwillflashandcannotbe *controlledvialeds-gpio.
*/ if (gpio_request(DNS323_GPIO_SYSTEM_UP, "SYS_READY") == 0)
gpio_direction_output(DNS323_GPIO_SYSTEM_UP, 1);
/* Poweroff GPIO */ if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
pr_err("DNS-323: failed to setup power-off GPIO\n");
register_platform_power_off(dns323b_power_off); break; case DNS323_REV_C1: /* 5182 built-in SATA init */
orion5x_sata_init(&dns323_sata_data);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.