parent
144fd07cd8
commit
5a481b16ad
@ -0,0 +1,178 @@ |
||||
/*
|
||||
* Copyright (C) 2008 Stanley Pinchak <stanley_dot_pinchak_at_gmail_dot_com> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
#ifndef __AR7_TITAN_H__ |
||||
#define __AR7_TITAN_H__ |
||||
|
||||
#ifndef __AR7_GPIO_H__ |
||||
#include <asm/ar7/gpio.h> |
||||
#endif |
||||
|
||||
typedef enum TITAN_GPIO_PIN_MODE_tag |
||||
{ |
||||
FUNCTIONAL_PIN = 0, |
||||
GPIO_PIN = 1 |
||||
} TITAN_GPIO_PIN_MODE_T; |
||||
|
||||
typedef enum TITAN_GPIO_PIN_DIRECTION_tag |
||||
{ |
||||
GPIO_OUTPUT_PIN = 0, |
||||
GPIO_INPUT_PIN = 1 |
||||
} TITAN_GPIO_PIN_DIRECTION_T; |
||||
|
||||
/**********************************************************************
|
||||
* GPIO Control |
||||
**********************************************************************/ |
||||
|
||||
typedef struct
|
||||
{ |
||||
int pinSelReg; |
||||
int shift; |
||||
int func; |
||||
|
||||
} GPIO_CFG; |
||||
|
||||
static GPIO_CFG gptable[]= { |
||||
/* PIN_SEL_REG, START_BIT, GPIO_CFG_MUX_VALUE */ |
||||
{4,24,1}, |
||||
{4,26,1}, |
||||
{4,28,1}, |
||||
{4,30,1}, |
||||
{5,6,1}, |
||||
{5,8,1}, |
||||
{5,10,1}, |
||||
{5,12,1}, |
||||
{7,14,3}, |
||||
{7,16,3}, |
||||
{7,18,3}, |
||||
{7,20,3}, |
||||
{7,22,3}, |
||||
{7,26,3}, |
||||
{7,28,3}, |
||||
{7,30,3}, |
||||
{8,0,3}, |
||||
{8,2,3}, |
||||
{8,4,3}, |
||||
{8,10,3}, |
||||
{8,14,3}, |
||||
{8,16,3}, |
||||
{8,18,3}, |
||||
{8,20,3}, |
||||
{9,8,3}, |
||||
{9,10,3}, |
||||
{9,12,3}, |
||||
{9,14,3}, |
||||
{9,18,3}, |
||||
{9,20,3}, |
||||
{9,24,3}, |
||||
{9,26,3}, |
||||
{9,28,3}, |
||||
{9,30,3}, |
||||
{10,0,3}, |
||||
{10,2,3}, |
||||
{10,8,3}, |
||||
{10,10,3}, |
||||
{10,12,3}, |
||||
{10,14,3}, |
||||
{13,12,3}, |
||||
{13,14,3}, |
||||
{13,16,3}, |
||||
{13,18,3}, |
||||
{13,24,3}, |
||||
{13,26,3}, |
||||
{13,28,3}, |
||||
{13,30,3}, |
||||
{14,2,3}, |
||||
{14,6,3}, |
||||
{14,8,3}, |
||||
{14,12,3} |
||||
}; |
||||
|
||||
typedef struct |
||||
{ |
||||
volatile unsigned int reg[21]; |
||||
} |
||||
PIN_SEL_REG_ARRAY_T; |
||||
|
||||
typedef struct |
||||
{ |
||||
unsigned int data_in [2]; |
||||
unsigned int data_out[2]; |
||||
unsigned int dir[2]; |
||||
unsigned int enable[2]; |
||||
|
||||
} TITAN_GPIO_CONTROL_T; |
||||
|
||||
#define AVALANCHE_PIN_SEL_BASE 0xA861160C /*replace with KSEG1ADDR()*/ |
||||
|
||||
static inline int titan_gpio_ctrl(unsigned int gpio_pin, TITAN_GPIO_PIN_MODE_T pin_mode, |
||||
TITAN_GPIO_PIN_DIRECTION_T pin_direction) |
||||
{ |
||||
int reg_index = 0; |
||||
int mux_status; |
||||
GPIO_CFG gpio_cfg; |
||||
volatile PIN_SEL_REG_ARRAY_T *pin_sel_array = (PIN_SEL_REG_ARRAY_T*) AVALANCHE_PIN_SEL_BASE; |
||||
volatile TITAN_GPIO_CONTROL_T *gpio_cntl = (TITAN_GPIO_CONTROL_T*) KSEG1ADDR(AR7_REGS_GPIO + TITAN_GPIO_INPUT_0); |
||||
|
||||
if (gpio_pin > 51 ) |
||||
return(-1); |
||||
|
||||
gpio_cfg = gptable[gpio_pin]; |
||||
mux_status = (pin_sel_array->reg[gpio_cfg.pinSelReg - 1] >> gpio_cfg.shift) & 0x3; |
||||
if(!((mux_status == 0 /* tri-stated */ ) || (mux_status == gpio_cfg.func /*GPIO functionality*/))) |
||||
{ |
||||
return(-1); /* Pin have been configured for non GPIO funcs. */ |
||||
} |
||||
|
||||
/* Set the pin to be used as GPIO. */ |
||||
pin_sel_array->reg[gpio_cfg.pinSelReg - 1] |= ((gpio_cfg.func & 0x3) << gpio_cfg.shift); |
||||
|
||||
/* Check whether gpio refers to the first GPIO reg or second. */ |
||||
if(gpio_pin > 31) |
||||
{ |
||||
reg_index = 1; |
||||
gpio_pin -= 32; |
||||
} |
||||
|
||||
if(pin_mode) |
||||
gpio_cntl->enable[reg_index] |= (1 << gpio_pin); /* Enable */ |
||||
else |
||||
gpio_cntl->enable[reg_index] &= ~(1 << gpio_pin); |
||||
|
||||
if(pin_direction) |
||||
gpio_cntl->dir[reg_index] |= (1 << gpio_pin); /* Input */ |
||||
else |
||||
gpio_cntl->dir[reg_index] &= ~(1 << gpio_pin); |
||||
|
||||
return(0); |
||||
|
||||
}/* end of function titan_gpio_ctrl */ |
||||
|
||||
static inline int titan_sysGpioInValue(unsigned int *in_val, unsigned int reg_index) |
||||
{ |
||||
volatile TITAN_GPIO_CONTROL_T *gpio_cntl = (TITAN_GPIO_CONTROL_T*) KSEG1ADDR(AR7_REGS_GPIO + TITAN_GPIO_INPUT_0); |
||||
|
||||
if(reg_index > 1) |
||||
return (-1); |
||||
|
||||
*in_val = gpio_cntl->data_in[reg_index]; |
||||
|
||||
return (0); |
||||
} |
||||
|
||||
|
||||
#endif |
@ -0,0 +1,248 @@ |
||||
--- a/arch/mips/ar7/platform.c 2009-11-18 14:57:44.000000000 +0800
|
||||
+++ b/arch/mips/ar7/platform.c 2009-11-18 15:43:04.000000000 +0800
|
||||
@@ -128,6 +128,36 @@
|
||||
},
|
||||
};
|
||||
|
||||
+static struct resource cpmac_low_res_titan[] = {
|
||||
+ {
|
||||
+ .name = "regs",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = TITAN_REGS_MAC0,
|
||||
+ .end = TITAN_REGS_MAC0 + 0x7ff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "irq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 27,
|
||||
+ .end = 27,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static struct resource cpmac_high_res_titan[] = {
|
||||
+ {
|
||||
+ .name = "regs",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = TITAN_REGS_MAC1,
|
||||
+ .end = TITAN_REGS_MAC1 + 0x7ff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "irq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 41,
|
||||
+ .end = 41,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
static struct resource vlynq_low_res[] = {
|
||||
{
|
||||
.name = "regs",
|
||||
@@ -182,6 +212,60 @@
|
||||
},
|
||||
};
|
||||
|
||||
+static struct resource vlynq_low_res_titan[] = {
|
||||
+ {
|
||||
+ .name = "regs",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = TITAN_REGS_VLYNQ0,
|
||||
+ .end = TITAN_REGS_VLYNQ0 + 0xff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "irq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 33,
|
||||
+ .end = 33,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "mem",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = 0x0c000000,
|
||||
+ .end = 0x0fffffff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "devirq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 80,
|
||||
+ .end = 111,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static struct resource vlynq_high_res_titan[] = {
|
||||
+ {
|
||||
+ .name = "regs",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = TITAN_REGS_VLYNQ1,
|
||||
+ .end = TITAN_REGS_VLYNQ1 + 0xff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "irq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 34,
|
||||
+ .end = 34,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "mem",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ .start = 0x40000000,
|
||||
+ .end = 0x43ffffff,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "devirq",
|
||||
+ .flags = IORESOURCE_IRQ,
|
||||
+ .start = 112,
|
||||
+ .end = 143,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
static struct resource usb_res[] = {
|
||||
{
|
||||
.name = "regs",
|
||||
@@ -226,6 +310,18 @@
|
||||
.phy_mask = 0x7fffffff,
|
||||
};
|
||||
|
||||
+static struct plat_cpmac_data cpmac_low_data_titan = {
|
||||
+ .reset_bit = 17,
|
||||
+ .power_bit = 20,
|
||||
+ .phy_mask = 0x40000000,
|
||||
+};
|
||||
+
|
||||
+static struct plat_cpmac_data cpmac_high_data_titan = {
|
||||
+ .reset_bit = 21,
|
||||
+ .power_bit = 22,
|
||||
+ .phy_mask = 0x80000000,
|
||||
+};
|
||||
+
|
||||
static struct plat_vlynq_data vlynq_low_data = {
|
||||
.ops.on = vlynq_on,
|
||||
.ops.off = vlynq_off,
|
||||
@@ -240,6 +336,20 @@
|
||||
.gpio_bit = 19,
|
||||
};
|
||||
|
||||
+static struct plat_vlynq_data vlynq_low_data_titan = {
|
||||
+ .ops.on = vlynq_on,
|
||||
+ .ops.off = vlynq_off,
|
||||
+ .reset_bit = 15,
|
||||
+ .gpio_bit = 14,
|
||||
+};
|
||||
+
|
||||
+static struct plat_vlynq_data vlynq_high_data_titan = {
|
||||
+ .ops.on = vlynq_on,
|
||||
+ .ops.off = vlynq_off,
|
||||
+ .reset_bit = 16,
|
||||
+ .gpio_bit = 7,
|
||||
+};
|
||||
+
|
||||
static struct platform_device physmap_flash = {
|
||||
.id = 0,
|
||||
.name = "physmap-flash",
|
||||
@@ -273,6 +383,30 @@
|
||||
.num_resources = ARRAY_SIZE(cpmac_high_res),
|
||||
};
|
||||
|
||||
+static struct platform_device cpmac_low_titan = {
|
||||
+ .id = 0,
|
||||
+ .name = "cpmac",
|
||||
+ .dev = {
|
||||
+ .dma_mask = &cpmac_dma_mask,
|
||||
+ .coherent_dma_mask = DMA_32BIT_MASK,
|
||||
+ .platform_data = &cpmac_low_data_titan,
|
||||
+ },
|
||||
+ .resource = cpmac_low_res_titan,
|
||||
+ .num_resources = ARRAY_SIZE(cpmac_low_res_titan),
|
||||
+};
|
||||
+
|
||||
+static struct platform_device cpmac_high_titan = {
|
||||
+ .id = 1,
|
||||
+ .name = "cpmac",
|
||||
+ .dev = {
|
||||
+ .dma_mask = &cpmac_dma_mask,
|
||||
+ .coherent_dma_mask = DMA_32BIT_MASK,
|
||||
+ .platform_data = &cpmac_high_data_titan,
|
||||
+ },
|
||||
+ .resource = cpmac_high_res_titan,
|
||||
+ .num_resources = ARRAY_SIZE(cpmac_high_res_titan),
|
||||
+};
|
||||
+
|
||||
static struct platform_device vlynq_low = {
|
||||
.id = 0,
|
||||
.name = "vlynq",
|
||||
@@ -289,6 +423,22 @@
|
||||
.num_resources = ARRAY_SIZE(vlynq_high_res),
|
||||
};
|
||||
|
||||
+static struct platform_device vlynq_low_titan = {
|
||||
+ .id = 0,
|
||||
+ .name = "vlynq",
|
||||
+ .dev.platform_data = &vlynq_low_data_titan,
|
||||
+ .resource = vlynq_low_res_titan,
|
||||
+ .num_resources = ARRAY_SIZE(vlynq_low_res_titan),
|
||||
+};
|
||||
+
|
||||
+static struct platform_device vlynq_high_titan = {
|
||||
+ .id = 1,
|
||||
+ .name = "vlynq",
|
||||
+ .dev.platform_data = &vlynq_high_data_titan,
|
||||
+ .resource = vlynq_high_res_titan,
|
||||
+ .num_resources = ARRAY_SIZE(vlynq_high_res_titan),
|
||||
+};
|
||||
+
|
||||
|
||||
/* This is proper way to define uart ports, but they are then detected
|
||||
* as xscale and, obviously, don't work...
|
||||
@@ -333,6 +483,11 @@
|
||||
{ .name = "status", .gpio = 8, .active_low = 1, },
|
||||
};
|
||||
|
||||
+static struct gpio_led titan_leds[] = {
|
||||
+ { .name = "status", .gpio = 8, .active_low = 1, },
|
||||
+ { .name = "wifi", .gpio = 13, .active_low = 1, },
|
||||
+};
|
||||
+
|
||||
static struct gpio_led dsl502t_leds[] = {
|
||||
{ .name = "status", .gpio = 9, .active_low = 1, },
|
||||
{ .name = "ethernet", .gpio = 7, .active_low = 1, },
|
||||
@@ -425,7 +580,7 @@
|
||||
/* FIXME: the whole thing is unreliable */
|
||||
prId = prom_getenv("ProductID");
|
||||
usb_prod = prom_getenv("usb_prod");
|
||||
-
|
||||
+
|
||||
/* If we can't get the product id from PROM, use the default LEDs */
|
||||
if (!prId)
|
||||
return;
|
||||
@@ -442,6 +597,9 @@
|
||||
} else if (strstr(prId, "DG834")) {
|
||||
ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds);
|
||||
ar7_led_data.leds = dg834g_leds;
|
||||
+ } else if (strstr(prId, "CYWM")) {
|
||||
+ ar7_led_data.num_leds = ARRAY_SIZE(titan_leds);
|
||||
+ ar7_led_data.leds = titan_leds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,14 +660,18 @@
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
- ar7_device_disable(vlynq_low_data.reset_bit);
|
||||
- res = platform_device_register(&vlynq_low);
|
||||
+ ar7_device_disable(ar7_is_titan() ? vlynq_low_data_titan.reset_bit :
|
||||
+ vlynq_low_data.reset_bit);
|
||||
+ res = platform_device_register(ar7_is_titan() ? &vlynq_low_titan :
|
||||
+ &vlynq_low);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (ar7_has_high_vlynq()) {
|
||||
- ar7_device_disable(vlynq_high_data.reset_bit);
|
||||
- res = platform_device_register(&vlynq_high);
|
||||
+ ar7_device_disable(ar7_is_titan() ? vlynq_high_data_titan.reset_bit :
|
||||
+ vlynq_high_data.reset_bit);
|
||||
+ res = platform_device_register(ar7_is_titan() ? &vlynq_high_titan :
|
||||
+ &vlynq_high);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
@ -0,0 +1,66 @@ |
||||
--- a/arch/mips/ar7/platform.c 2009-11-18 15:47:42.000000000 +0800
|
||||
+++ b/arch/mips/ar7/platform.c 2009-11-19 00:56:05.000000000 +0800
|
||||
@@ -677,24 +677,32 @@
|
||||
}
|
||||
|
||||
if (ar7_has_high_cpmac()) {
|
||||
- res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status);
|
||||
+ res = fixed_phy_add(PHY_POLL, ar7_is_titan()?cpmac_high_titan.id: cpmac_high.id, &fixed_phy_status);
|
||||
if (res && res != -ENODEV)
|
||||
return res;
|
||||
|
||||
- cpmac_get_mac(1, cpmac_high_data.dev_addr);
|
||||
- res = platform_device_register(&cpmac_high);
|
||||
+ cpmac_get_mac(1, ar7_is_titan() ? cpmac_high_data_titan.dev_addr:
|
||||
+ cpmac_high_data.dev_addr);
|
||||
+ res = platform_device_register(ar7_is_titan() ? &cpmac_high_titan :
|
||||
+ &cpmac_high);
|
||||
if (res)
|
||||
return res;
|
||||
} else {
|
||||
- cpmac_low_data.phy_mask = 0xffffffff;
|
||||
- }
|
||||
+ if (ar7_is_titan())
|
||||
+ cpmac_low_data_titan.phy_mask = 0xffffffff;
|
||||
+ else
|
||||
+ cpmac_low_data.phy_mask = 0xffffffff;
|
||||
+ }
|
||||
|
||||
- res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status);
|
||||
+ res = fixed_phy_add(PHY_POLL, ar7_is_titan()?cpmac_low_titan.id:
|
||||
+ cpmac_low.id, &fixed_phy_status);
|
||||
if (res && res != -ENODEV)
|
||||
return res;
|
||||
|
||||
- cpmac_get_mac(0, cpmac_low_data.dev_addr);
|
||||
- res = platform_device_register(&cpmac_low);
|
||||
+ cpmac_get_mac(0, ar7_is_titan() ? cpmac_low_data_titan.dev_addr :
|
||||
+ cpmac_low_data.dev_addr);
|
||||
+ res = platform_device_register(ar7_is_titan() ? &cpmac_low_titan :
|
||||
+ &cpmac_low);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
--- a/drivers/net/cpmac.c 2009-11-18 15:47:42.000000000 +0800
|
||||
+++ b/drivers/net/cpmac.c 2009-11-19 00:58:25.000000000 +0800
|
||||
@@ -1236,6 +1236,10 @@
|
||||
ar7_device_reset(AR7_RESET_BIT_CPMAC_HI);
|
||||
ar7_device_reset(AR7_RESET_BIT_EPHY);
|
||||
|
||||
+ if (ar7_is_titan()) {
|
||||
+ ar7_device_reset(TITAN_RESET_BIT_EPHY1);
|
||||
+ }
|
||||
+
|
||||
cpmac_mii->reset(cpmac_mii);
|
||||
|
||||
for (i = 0; i < 300; i++)
|
||||
@@ -1250,7 +1254,8 @@
|
||||
mask = 0;
|
||||
}
|
||||
|
||||
- cpmac_mii->phy_mask = ~(mask | 0x80000000);
|
||||
+ cpmac_mii->phy_mask = ar7_is_titan()? ~(mask | 0x80000000 | 0x40000000):
|
||||
+ ~(mask | 0x80000000);
|
||||
snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1");
|
||||
|
||||
res = mdiobus_register(cpmac_mii);
|
Loading…
Reference in new issue