ar8216: factor out chip-specific data structures from ar8xxx_priv
Factor out chip-specific data structures from ar8xxx_priv. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 43469
This commit is contained in:
parent
a3b651635f
commit
ea9324f3d3
1 changed files with 16 additions and 15 deletions
|
@ -146,9 +146,7 @@ struct ar8xxx_priv {
|
||||||
u8 chip_ver;
|
u8 chip_ver;
|
||||||
u8 chip_rev;
|
u8 chip_rev;
|
||||||
const struct ar8xxx_chip *chip;
|
const struct ar8xxx_chip *chip;
|
||||||
union {
|
void *chip_data;
|
||||||
struct ar8327_data ar8327;
|
|
||||||
} chip_data;
|
|
||||||
bool initialized;
|
bool initialized;
|
||||||
bool port4_phy;
|
bool port4_phy;
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
|
@ -1412,7 +1410,7 @@ static int
|
||||||
ar8327_led_create(struct ar8xxx_priv *priv,
|
ar8327_led_create(struct ar8xxx_priv *priv,
|
||||||
const struct ar8327_led_info *led_info)
|
const struct ar8327_led_info *led_info)
|
||||||
{
|
{
|
||||||
struct ar8327_data *data = &priv->chip_data.ar8327;
|
struct ar8327_data *data = priv->chip_data;
|
||||||
struct ar8327_led *aled;
|
struct ar8327_led *aled;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1473,14 +1471,12 @@ ar8327_led_destroy(struct ar8327_led *aled)
|
||||||
static void
|
static void
|
||||||
ar8327_leds_init(struct ar8xxx_priv *priv)
|
ar8327_leds_init(struct ar8xxx_priv *priv)
|
||||||
{
|
{
|
||||||
struct ar8327_data *data;
|
struct ar8327_data *data = priv->chip_data;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS))
|
if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data = &priv->chip_data.ar8327;
|
|
||||||
|
|
||||||
for (i = 0; i < data->num_leds; i++) {
|
for (i = 0; i < data->num_leds; i++) {
|
||||||
struct ar8327_led *aled;
|
struct ar8327_led *aled;
|
||||||
|
|
||||||
|
@ -1498,7 +1494,7 @@ ar8327_leds_init(struct ar8xxx_priv *priv)
|
||||||
static void
|
static void
|
||||||
ar8327_leds_cleanup(struct ar8xxx_priv *priv)
|
ar8327_leds_cleanup(struct ar8xxx_priv *priv)
|
||||||
{
|
{
|
||||||
struct ar8327_data *data = &priv->chip_data.ar8327;
|
struct ar8327_data *data = priv->chip_data;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS))
|
if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS))
|
||||||
|
@ -1519,7 +1515,7 @@ ar8327_hw_config_pdata(struct ar8xxx_priv *priv,
|
||||||
struct ar8327_platform_data *pdata)
|
struct ar8327_platform_data *pdata)
|
||||||
{
|
{
|
||||||
struct ar8327_led_cfg *led_cfg;
|
struct ar8327_led_cfg *led_cfg;
|
||||||
struct ar8327_data *data;
|
struct ar8327_data *data = priv->chip_data;
|
||||||
u32 pos, new_pos;
|
u32 pos, new_pos;
|
||||||
u32 t;
|
u32 t;
|
||||||
|
|
||||||
|
@ -1528,8 +1524,6 @@ ar8327_hw_config_pdata(struct ar8xxx_priv *priv,
|
||||||
|
|
||||||
priv->get_port_link = pdata->get_port_link;
|
priv->get_port_link = pdata->get_port_link;
|
||||||
|
|
||||||
data = &priv->chip_data.ar8327;
|
|
||||||
|
|
||||||
data->port0_status = ar8327_get_port_init_status(&pdata->port0_cfg);
|
data->port0_status = ar8327_get_port_init_status(&pdata->port0_cfg);
|
||||||
data->port6_status = ar8327_get_port_init_status(&pdata->port6_cfg);
|
data->port6_status = ar8327_get_port_init_status(&pdata->port6_cfg);
|
||||||
|
|
||||||
|
@ -1602,6 +1596,7 @@ ar8327_hw_config_pdata(struct ar8xxx_priv *priv,
|
||||||
static int
|
static int
|
||||||
ar8327_hw_config_of(struct ar8xxx_priv *priv, struct device_node *np)
|
ar8327_hw_config_of(struct ar8xxx_priv *priv, struct device_node *np)
|
||||||
{
|
{
|
||||||
|
struct ar8327_data *data = priv->chip_data;
|
||||||
const __be32 *paddr;
|
const __be32 *paddr;
|
||||||
int len;
|
int len;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1621,10 +1616,10 @@ ar8327_hw_config_of(struct ar8xxx_priv *priv, struct device_node *np)
|
||||||
|
|
||||||
switch (reg) {
|
switch (reg) {
|
||||||
case AR8327_REG_PORT_STATUS(0):
|
case AR8327_REG_PORT_STATUS(0):
|
||||||
priv->chip_data.ar8327.port0_status = val;
|
data->port0_status = val;
|
||||||
break;
|
break;
|
||||||
case AR8327_REG_PORT_STATUS(6):
|
case AR8327_REG_PORT_STATUS(6):
|
||||||
priv->chip_data.ar8327.port6_status = val;
|
data->port6_status = val;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
priv->write(priv, reg, val);
|
priv->write(priv, reg, val);
|
||||||
|
@ -1647,6 +1642,10 @@ ar8327_hw_init(struct ar8xxx_priv *priv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
priv->chip_data = kzalloc(sizeof(struct ar8327_data), GFP_KERNEL);
|
||||||
|
if (!priv->chip_data)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (priv->phy->dev.of_node)
|
if (priv->phy->dev.of_node)
|
||||||
ret = ar8327_hw_config_of(priv, priv->phy->dev.of_node);
|
ret = ar8327_hw_config_of(priv, priv->phy->dev.of_node);
|
||||||
else
|
else
|
||||||
|
@ -1706,12 +1705,13 @@ ar8327_init_globals(struct ar8xxx_priv *priv)
|
||||||
static void
|
static void
|
||||||
ar8327_init_port(struct ar8xxx_priv *priv, int port)
|
ar8327_init_port(struct ar8xxx_priv *priv, int port)
|
||||||
{
|
{
|
||||||
|
struct ar8327_data *data = priv->chip_data;
|
||||||
u32 t;
|
u32 t;
|
||||||
|
|
||||||
if (port == AR8216_PORT_CPU)
|
if (port == AR8216_PORT_CPU)
|
||||||
t = priv->chip_data.ar8327.port0_status;
|
t = data->port0_status;
|
||||||
else if (port == 6)
|
else if (port == 6)
|
||||||
t = priv->chip_data.ar8327.port6_status;
|
t = data->port6_status;
|
||||||
else
|
else
|
||||||
t = AR8216_PORT_STATUS_LINK_AUTO;
|
t = AR8216_PORT_STATUS_LINK_AUTO;
|
||||||
|
|
||||||
|
@ -2700,6 +2700,7 @@ ar8xxx_free(struct ar8xxx_priv *priv)
|
||||||
if (priv->chip && priv->chip->cleanup)
|
if (priv->chip && priv->chip->cleanup)
|
||||||
priv->chip->cleanup(priv);
|
priv->chip->cleanup(priv);
|
||||||
|
|
||||||
|
kfree(priv->chip_data);
|
||||||
kfree(priv->mib_stats);
|
kfree(priv->mib_stats);
|
||||||
kfree(priv);
|
kfree(priv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue