Commit 1618df6a authored by Jonathan Lemon's avatar Jonathan Lemon Committed by David S. Miller

ptp: ocp: parameterize the i2c driver used

Move the xilinx i2c driver parameters to the resource block instead
of hardcoding things in the registration functions.
Signed-off-by: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c6887214
...@@ -131,6 +131,13 @@ struct ptp_ocp_flash_info { ...@@ -131,6 +131,13 @@ struct ptp_ocp_flash_info {
void *data; void *data;
}; };
struct ptp_ocp_i2c_info {
const char *name;
unsigned long fixed_rate;
size_t data_size;
void *data;
};
struct ptp_ocp_ext_info { struct ptp_ocp_ext_info {
const char *name; const char *name;
int index; int index;
...@@ -269,6 +276,10 @@ static struct ocp_resource ocp_fb_resource[] = { ...@@ -269,6 +276,10 @@ static struct ocp_resource ocp_fb_resource[] = {
{ {
OCP_I2C_RESOURCE(i2c_ctrl), OCP_I2C_RESOURCE(i2c_ctrl),
.offset = 0x00150000, .size = 0x10000, .irq_vec = 7, .offset = 0x00150000, .size = 0x10000, .irq_vec = 7,
.extra = &(struct ptp_ocp_i2c_info) {
.name = "xiic-i2c",
.fixed_rate = 50000000,
},
}, },
{ {
OCP_SERIAL_RESOURCE(gnss_port), OCP_SERIAL_RESOURCE(gnss_port),
...@@ -944,21 +955,25 @@ ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r) ...@@ -944,21 +955,25 @@ ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r)
static struct platform_device * static struct platform_device *
ptp_ocp_i2c_bus(struct pci_dev *pdev, struct ocp_resource *r, int id) ptp_ocp_i2c_bus(struct pci_dev *pdev, struct ocp_resource *r, int id)
{ {
struct ptp_ocp_i2c_info *info;
struct resource res[2]; struct resource res[2];
unsigned long start; unsigned long start;
info = r->extra;
start = pci_resource_start(pdev, 0) + r->offset; start = pci_resource_start(pdev, 0) + r->offset;
ptp_ocp_set_mem_resource(&res[0], start, r->size); ptp_ocp_set_mem_resource(&res[0], start, r->size);
ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec)); ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec));
return platform_device_register_resndata(&pdev->dev, "xiic-i2c", return platform_device_register_resndata(&pdev->dev, info->name,
id, res, 2, NULL, 0); id, res, 2,
info->data, info->data_size);
} }
static int static int
ptp_ocp_register_i2c(struct ptp_ocp *bp, struct ocp_resource *r) ptp_ocp_register_i2c(struct ptp_ocp *bp, struct ocp_resource *r)
{ {
struct pci_dev *pdev = bp->pdev; struct pci_dev *pdev = bp->pdev;
struct ptp_ocp_i2c_info *info;
struct platform_device *p; struct platform_device *p;
struct clk_hw *clk; struct clk_hw *clk;
char buf[32]; char buf[32];
...@@ -970,15 +985,17 @@ ptp_ocp_register_i2c(struct ptp_ocp *bp, struct ocp_resource *r) ...@@ -970,15 +985,17 @@ ptp_ocp_register_i2c(struct ptp_ocp *bp, struct ocp_resource *r)
return 0; return 0;
} }
info = r->extra;
id = pci_dev_id(bp->pdev); id = pci_dev_id(bp->pdev);
sprintf(buf, "AXI.%d", id); sprintf(buf, "AXI.%d", id);
clk = clk_hw_register_fixed_rate(&pdev->dev, buf, NULL, 0, 50000000); clk = clk_hw_register_fixed_rate(&pdev->dev, buf, NULL, 0,
info->fixed_rate);
if (IS_ERR(clk)) if (IS_ERR(clk))
return PTR_ERR(clk); return PTR_ERR(clk);
bp->i2c_clk = clk; bp->i2c_clk = clk;
sprintf(buf, "xiic-i2c.%d", id); sprintf(buf, "%s.%d", info->name, id);
devm_clk_hw_register_clkdev(&pdev->dev, clk, NULL, buf); devm_clk_hw_register_clkdev(&pdev->dev, clk, NULL, buf);
p = ptp_ocp_i2c_bus(bp->pdev, r, id); p = ptp_ocp_i2c_bus(bp->pdev, r, id);
if (IS_ERR(p)) if (IS_ERR(p))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment