Skip to content

Commit

Permalink
POWERPC: Bring the fs_no calculation to the relevant SoC enumeration
Browse files Browse the repository at this point in the history
The fs_no mean used to be fs_enet driver driven, hence it was an
enumeration across all the possible fs_enet "users" in the SoC. Now, with
QE on the pipeline, and to make DTS descriptions more clear, fs_no features
relevant SoC part number, with additional field to describe the SoC type.

Another reason for that is now not only fs_enet is going to utilize those
stuff. There might be UART, HLDC, and even USB, so to prevent confusion and
be ready for upcoming OF_device transfer, fs_enet and cpm_uart drivers were
updated in that concern, as well as the relevant DTS.

Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
  • Loading branch information
Vitaly Bordug committed Sep 21, 2006
1 parent d3465c9 commit 611a15a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 9 deletions.
8 changes: 4 additions & 4 deletions arch/powerpc/boot/dts/mpc8560ads.dts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
device_type = "serial";
compatible = "cpm_uart";
model = "SCC";
device-id = <2>;
device-id = <1>;
reg = <91a00 20 88000 100>;
clock-setup = <00ffffff 0>;
rx-clock = <1>;
Expand All @@ -258,7 +258,7 @@
device_type = "serial";
compatible = "cpm_uart";
model = "SCC";
device-id = <3>;
device-id = <2>;
reg = <91a20 20 88100 100>;
clock-setup = <ff00ffff 90000>;
rx-clock = <2>;
Expand All @@ -272,7 +272,7 @@
device_type = "network";
compatible = "fs_enet";
model = "FCC";
device-id = <3>;
device-id = <2>;
reg = <91320 20 88500 100 913a0 30>;
mac-address = [ 00 00 0C 00 02 FD ];
clock-setup = <ff00ffff 250000>;
Expand All @@ -287,7 +287,7 @@
device_type = "network";
compatible = "fs_enet";
model = "FCC";
device-id = <4>;
device-id = <3>;
reg = <91340 20 88600 100 913d0 30>;
mac-address = [ 00 00 0C 00 03 FD ];
clock-setup = <ffff00ff 3700>;
Expand Down
8 changes: 7 additions & 1 deletion arch/powerpc/sysdev/fsl_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ static int __init fs_enet_of_init(void)

id = get_property(np, "device-id", NULL);
fs_enet_data.fs_no = *id;
strcpy(fs_enet_data.fs_type, model);

mdio = of_get_parent(phy);
ret = of_address_to_resource(mdio, 0, &res);
Expand All @@ -635,7 +636,7 @@ static int __init fs_enet_of_init(void)
fs_enet_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL));

if (strstr(model, "FCC")) {
int fcc_index = fs_get_fcc_index(*id);
int fcc_index = *id - 1;

fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0);
fs_enet_data.rx_ring = 32;
Expand Down Expand Up @@ -688,6 +689,7 @@ static int __init cpm_uart_of_init(void)
struct resource r[3];
struct fs_uart_platform_info cpm_uart_data;
const int *id;
const char *model;

memset(r, 0, sizeof(r));
memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
Expand Down Expand Up @@ -716,6 +718,10 @@ static int __init cpm_uart_of_init(void)

id = get_property(np, "device-id", NULL);
cpm_uart_data.fs_no = *id;

model = (char*)get_property(np, "model", NULL);
strcpy(cpm_uart_data.fs_type, model);

cpm_uart_data.uart_clk = ppc_proc_freq;

cpm_uart_data.tx_num_fifo = 4;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/fs_enet/fs_enet-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,12 +944,13 @@ extern int fs_mii_connect(struct net_device *dev);
extern void fs_mii_disconnect(struct net_device *dev);

static struct net_device *fs_init_instance(struct device *dev,
const struct fs_platform_info *fpi)
struct fs_platform_info *fpi)
{
struct net_device *ndev = NULL;
struct fs_enet_private *fep = NULL;
int privsize, i, r, err = 0, registered = 0;

fpi->fs_no = fs_get_id(fpi);
/* guard */
if ((unsigned int)fpi->fs_no >= FS_MAX_INDEX)
return ERR_PTR(-EINVAL);
Expand Down
9 changes: 6 additions & 3 deletions drivers/serial/cpm_uart/cpm_uart_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,15 +1023,17 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
{
struct resource *r;
struct fs_uart_platform_info *pdata = pdev->dev.platform_data;
int idx = pdata->fs_no; /* It is UART_SMCx or UART_SCCx index */
int idx; /* It is UART_SMCx or UART_SCCx index */
struct uart_cpm_port *pinfo;
int line;
u32 mem, pram;

idx = pdata->fs_no = fs_uart_get_id(pdata);

line = cpm_uart_id2nr(idx);
if(line < 0) {
printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx);
return -1;
return -EINVAL;
}

pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx];
Expand Down Expand Up @@ -1263,11 +1265,12 @@ static int cpm_uart_drv_probe(struct device *dev)
}

pdata = pdev->dev.platform_data;
pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no));

if ((ret = cpm_uart_drv_get_platform_data(pdev, 0)))
return ret;

pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no));

if (pdata->init_ioports)
pdata->init_ioports(pdata);

Expand Down
37 changes: 37 additions & 0 deletions include/linux/fs_enet_pd.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ static inline int fs_get_scc_index(enum fs_id id)
return -1;
}

static inline int fs_fec_index2id(int index)
{
int id = fsid_fec1 + index - 1;
if (id >= fsid_fec1 && id <= fsid_fec2)
return id;
return FS_MAX_INDEX;
}

static inline int fs_fcc_index2id(int index)
{
int id = fsid_fcc1 + index - 1;
if (id >= fsid_fcc1 && id <= fsid_fcc3)
return id;
return FS_MAX_INDEX;
}

static inline int fs_scc_index2id(int index)
{
int id = fsid_scc1 + index - 1;
if (id >= fsid_scc1 && id <= fsid_scc4)
return id;
return FS_MAX_INDEX;
}

enum fs_mii_method {
fsmii_fixed,
fsmii_fec,
Expand Down Expand Up @@ -91,6 +115,7 @@ struct fs_platform_info {
void(*init_ioports)(struct fs_platform_info *);
/* device specific information */
int fs_no; /* controller index */
char fs_type[4]; /* controller type */

u32 cp_page; /* CPM page */
u32 cp_block; /* CPM sblock */
Expand Down Expand Up @@ -126,4 +151,16 @@ struct fs_mii_fec_platform_info {
u32 irq[32];
u32 mii_speed;
};

static inline int fs_get_id(struct fs_platform_info *fpi)
{
if(strstr(fpi->fs_type, "SCC"))
return fs_scc_index2id(fpi->fs_no);
if(strstr(fpi->fs_type, "FCC"))
return fs_fcc_index2id(fpi->fs_no);
if(strstr(fpi->fs_type, "FEC"))
return fs_fec_index2id(fpi->fs_no);
return fpi->fs_no;
}

#endif
10 changes: 10 additions & 0 deletions include/linux/fs_uart_pd.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct fs_uart_platform_info {
void(*init_ioports)(struct fs_uart_platform_info *);
/* device specific information */
int fs_no; /* controller index */
char fs_type[4]; /* controller type */
u32 uart_clk;
u8 tx_num_fifo;
u8 tx_buf_size;
Expand All @@ -59,4 +60,13 @@ struct fs_uart_platform_info {
u8 clk_tx;
};

static inline int fs_uart_get_id(struct fs_uart_platform_info *fpi)
{
if(strstr(fpi->fs_type, "SMC"))
return fs_uart_id_smc2fsid(fpi->fs_no);
if(strstr(fpi->fs_type, "SCC"))
return fs_uart_id_scc2fsid(fpi->fs_no);
return fpi->fs_no;
}

#endif

0 comments on commit 611a15a

Please sign in to comment.