* [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook
2015-12-24 17:42 [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
@ 2015-12-24 17:42 ` Damien Riegel
2016-01-12 7:52 ` Marc Kleine-Budde
2015-12-24 17:42 ` [PATCH v2 2/3] can: sja1000: add documentation for Technologic Systems version Damien Riegel
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Damien Riegel @ 2015-12-24 17:42 UTC (permalink / raw)
To: linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, Marc Kleine-Budde, kernel, Damien Riegel
This commit adds the capability to allocate and init private data
embedded in the sja1000_priv structure on a per-compatible basis. The
device node is passed as a parameter of the init callback to allow
parsing of custom device tree properties.
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
drivers/net/can/sja1000/sja1000_platform.c | 39 ++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 0552ed4..e0572d0 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -40,6 +40,11 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
MODULE_ALIAS("platform:" DRV_NAME);
MODULE_LICENSE("GPL v2");
+struct sja1000_of_data {
+ size_t priv_sz;
+ int (*init)(struct sja1000_priv *priv, struct device_node *of);
+};
+
static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
{
return ioread8(priv->reg_base + reg);
@@ -154,7 +159,8 @@ static void sp_populate_of(struct sja1000_priv *priv, struct device_node *of)
priv->cdr |= CDR_CBP; /* default */
}
-static int sp_probe(struct platform_device *pdev)
+static int __sp_probe(struct platform_device *pdev,
+ const struct sja1000_of_data *of_data)
{
int err, irq = 0;
void __iomem *addr;
@@ -163,6 +169,7 @@ static int sp_probe(struct platform_device *pdev)
struct resource *res_mem, *res_irq = NULL;
struct sja1000_platform_data *pdata;
struct device_node *of = pdev->dev.of_node;
+ size_t priv_sz = of_data ? of_data->priv_sz : 0;
pdata = dev_get_platdata(&pdev->dev);
if (!pdata && !of) {
@@ -191,7 +198,7 @@ static int sp_probe(struct platform_device *pdev)
if (!irq && !res_irq)
return -ENODEV;
- dev = alloc_sja1000dev(0);
+ dev = alloc_sja1000dev(priv_sz);
if (!dev)
return -ENOMEM;
priv = netdev_priv(dev);
@@ -213,6 +220,12 @@ static int sp_probe(struct platform_device *pdev)
else
sp_populate(priv, pdata, res_mem->flags);
+ if (of_data && of_data->init) {
+ err = of_data->init(priv, of);
+ if (err)
+ goto exit_free;
+ }
+
platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -248,6 +261,28 @@ static const struct of_device_id sp_of_table[] = {
};
MODULE_DEVICE_TABLE(of, sp_of_table);
+static const struct sja1000_of_data *sp_get_of_data(struct device_node *of)
+{
+ const struct of_device_id *id;
+
+ if (!of)
+ return NULL;
+
+ id = of_match_node(sp_of_table, of);
+ if (!id)
+ return NULL;
+
+ return id->data;
+}
+
+static int sp_probe(struct platform_device *pdev)
+{
+ struct device_node *of = pdev->dev.of_node;
+ const struct sja1000_of_data *of_data = sp_get_of_data(of);
+
+ return __sp_probe(pdev, of_data);
+}
+
static struct platform_driver sp_driver = {
.probe = sp_probe,
.remove = sp_remove,
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook
2015-12-24 17:42 ` [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook Damien Riegel
@ 2016-01-12 7:52 ` Marc Kleine-Budde
2016-01-12 15:53 ` Damien Riegel
0 siblings, 1 reply; 11+ messages in thread
From: Marc Kleine-Budde @ 2016-01-12 7:52 UTC (permalink / raw)
To: Damien Riegel, linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, kernel
[-- Attachment #1: Type: text/plain, Size: 3642 bytes --]
On 12/24/2015 06:42 PM, Damien Riegel wrote:
> This commit adds the capability to allocate and init private data
> embedded in the sja1000_priv structure on a per-compatible basis. The
> device node is passed as a parameter of the init callback to allow
> parsing of custom device tree properties.
>
> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> ---
> drivers/net/can/sja1000/sja1000_platform.c | 39 ++++++++++++++++++++++++++++--
> 1 file changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
> index 0552ed4..e0572d0 100644
> --- a/drivers/net/can/sja1000/sja1000_platform.c
> +++ b/drivers/net/can/sja1000/sja1000_platform.c
> @@ -40,6 +40,11 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
> MODULE_ALIAS("platform:" DRV_NAME);
> MODULE_LICENSE("GPL v2");
>
> +struct sja1000_of_data {
> + size_t priv_sz;
> + int (*init)(struct sja1000_priv *priv, struct device_node *of);
> +};
> +
> static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
> {
> return ioread8(priv->reg_base + reg);
> @@ -154,7 +159,8 @@ static void sp_populate_of(struct sja1000_priv *priv, struct device_node *of)
> priv->cdr |= CDR_CBP; /* default */
> }
>
> -static int sp_probe(struct platform_device *pdev)
> +static int __sp_probe(struct platform_device *pdev,
> + const struct sja1000_of_data *of_data)
> {
> int err, irq = 0;
> void __iomem *addr;
> @@ -163,6 +169,7 @@ static int sp_probe(struct platform_device *pdev)
> struct resource *res_mem, *res_irq = NULL;
> struct sja1000_platform_data *pdata;
> struct device_node *of = pdev->dev.of_node;
> + size_t priv_sz = of_data ? of_data->priv_sz : 0;
>
> pdata = dev_get_platdata(&pdev->dev);
> if (!pdata && !of) {
> @@ -191,7 +198,7 @@ static int sp_probe(struct platform_device *pdev)
> if (!irq && !res_irq)
> return -ENODEV;
>
> - dev = alloc_sja1000dev(0);
> + dev = alloc_sja1000dev(priv_sz);
> if (!dev)
> return -ENOMEM;
> priv = netdev_priv(dev);
> @@ -213,6 +220,12 @@ static int sp_probe(struct platform_device *pdev)
> else
> sp_populate(priv, pdata, res_mem->flags);
>
> + if (of_data && of_data->init) {
> + err = of_data->init(priv, of);
> + if (err)
> + goto exit_free;
> + }
> +
> platform_set_drvdata(pdev, dev);
> SET_NETDEV_DEV(dev, &pdev->dev);
>
> @@ -248,6 +261,28 @@ static const struct of_device_id sp_of_table[] = {
> };
> MODULE_DEVICE_TABLE(of, sp_of_table);
>
> +static const struct sja1000_of_data *sp_get_of_data(struct device_node *of)
> +{
> + const struct of_device_id *id;
> +
> + if (!of)
> + return NULL;
> +
> + id = of_match_node(sp_of_table, of);
> + if (!id)
> + return NULL;
> +
> + return id->data;
> +}
> +
> +static int sp_probe(struct platform_device *pdev)
> +{
> + struct device_node *of = pdev->dev.of_node;
> + const struct sja1000_of_data *of_data = sp_get_of_data(of);
> +
> + return __sp_probe(pdev, of_data);
> +}
Please merge these two into the original sp_probe function, as there
already is a test for pdev->dev.of_node.
> +
> static struct platform_driver sp_driver = {
> .probe = sp_probe,
> .remove = sp_remove,
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook
2016-01-12 7:52 ` Marc Kleine-Budde
@ 2016-01-12 15:53 ` Damien Riegel
2016-01-12 16:24 ` Marc Kleine-Budde
0 siblings, 1 reply; 11+ messages in thread
From: Damien Riegel @ 2016-01-12 15:53 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-kernel, netdev, linux-can, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala, Wolfgang Grandegger,
kernel
On Tue, Jan 12, 2016 at 08:52:06AM +0100, Marc Kleine-Budde wrote:
> On 12/24/2015 06:42 PM, Damien Riegel wrote:
> > This commit adds the capability to allocate and init private data
> > embedded in the sja1000_priv structure on a per-compatible basis. The
> > device node is passed as a parameter of the init callback to allow
> > parsing of custom device tree properties.
> >
> > Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> > ---
> > drivers/net/can/sja1000/sja1000_platform.c | 39 ++++++++++++++++++++++++++++--
> > 1 file changed, 37 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
> > index 0552ed4..e0572d0 100644
> > --- a/drivers/net/can/sja1000/sja1000_platform.c
> > +++ b/drivers/net/can/sja1000/sja1000_platform.c
> > @@ -40,6 +40,11 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
> > MODULE_ALIAS("platform:" DRV_NAME);
> > MODULE_LICENSE("GPL v2");
> >
> > +struct sja1000_of_data {
> > + size_t priv_sz;
> > + int (*init)(struct sja1000_priv *priv, struct device_node *of);
> > +};
> > +
> > static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
> > {
> > return ioread8(priv->reg_base + reg);
> > @@ -154,7 +159,8 @@ static void sp_populate_of(struct sja1000_priv *priv, struct device_node *of)
> > priv->cdr |= CDR_CBP; /* default */
> > }
> >
> > -static int sp_probe(struct platform_device *pdev)
> > +static int __sp_probe(struct platform_device *pdev,
> > + const struct sja1000_of_data *of_data)
> > {
> > int err, irq = 0;
> > void __iomem *addr;
> > @@ -163,6 +169,7 @@ static int sp_probe(struct platform_device *pdev)
> > struct resource *res_mem, *res_irq = NULL;
> > struct sja1000_platform_data *pdata;
> > struct device_node *of = pdev->dev.of_node;
> > + size_t priv_sz = of_data ? of_data->priv_sz : 0;
> >
> > pdata = dev_get_platdata(&pdev->dev);
> > if (!pdata && !of) {
> > @@ -191,7 +198,7 @@ static int sp_probe(struct platform_device *pdev)
> > if (!irq && !res_irq)
> > return -ENODEV;
> >
> > - dev = alloc_sja1000dev(0);
> > + dev = alloc_sja1000dev(priv_sz);
> > if (!dev)
> > return -ENOMEM;
> > priv = netdev_priv(dev);
> > @@ -213,6 +220,12 @@ static int sp_probe(struct platform_device *pdev)
> > else
> > sp_populate(priv, pdata, res_mem->flags);
> >
> > + if (of_data && of_data->init) {
> > + err = of_data->init(priv, of);
> > + if (err)
> > + goto exit_free;
> > + }
> > +
> > platform_set_drvdata(pdev, dev);
> > SET_NETDEV_DEV(dev, &pdev->dev);
> >
> > @@ -248,6 +261,28 @@ static const struct of_device_id sp_of_table[] = {
> > };
> > MODULE_DEVICE_TABLE(of, sp_of_table);
> >
> > +static const struct sja1000_of_data *sp_get_of_data(struct device_node *of)
> > +{
> > + const struct of_device_id *id;
> > +
> > + if (!of)
> > + return NULL;
> > +
> > + id = of_match_node(sp_of_table, of);
> > + if (!id)
> > + return NULL;
> > +
> > + return id->data;
> > +}
> > +
> > +static int sp_probe(struct platform_device *pdev)
> > +{
> > + struct device_node *of = pdev->dev.of_node;
> > + const struct sja1000_of_data *of_data = sp_get_of_data(of);
> > +
> > + return __sp_probe(pdev, of_data);
> > +}
>
> Please merge these two into the original sp_probe function, as there
> already is a test for pdev->dev.of_node.
Ok. sp_get_of_data makes use of sp_of_table, so either I move sp_probe
below sp_of_table, or I use a forward declaration. Which one do you
prefer?
Damien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook
2016-01-12 15:53 ` Damien Riegel
@ 2016-01-12 16:24 ` Marc Kleine-Budde
0 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2016-01-12 16:24 UTC (permalink / raw)
To: Damien Riegel
Cc: linux-kernel, netdev, linux-can, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala, Wolfgang Grandegger,
kernel
On January 12, 2016 4:53:30 PM GMT+01:00, Damien Riegel <damien.riegel@savoirfairelinux.com> wrote:
>On Tue, Jan 12, 2016 at 08:52:06AM +0100, Marc Kleine-Budde wrote:
>> On 12/24/2015 06:42 PM, Damien Riegel wrote:
>> > This commit adds the capability to allocate and init private data
>> > embedded in the sja1000_priv structure on a per-compatible basis.
>The
>> > device node is passed as a parameter of the init callback to allow
>> > parsing of custom device tree properties.
>> >
>> > Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
>> > ---
>> > drivers/net/can/sja1000/sja1000_platform.c | 39
>++++++++++++++++++++++++++++--
>> > 1 file changed, 37 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/net/can/sja1000/sja1000_platform.c
>b/drivers/net/can/sja1000/sja1000_platform.c
>> > index 0552ed4..e0572d0 100644
>> > --- a/drivers/net/can/sja1000/sja1000_platform.c
>> > +++ b/drivers/net/can/sja1000/sja1000_platform.c
>> > @@ -40,6 +40,11 @@ MODULE_DESCRIPTION("Socket-CAN driver for
>SJA1000 on the platform bus");
>> > MODULE_ALIAS("platform:" DRV_NAME);
>> > MODULE_LICENSE("GPL v2");
>> >
>> > +struct sja1000_of_data {
>> > + size_t priv_sz;
>> > + int (*init)(struct sja1000_priv *priv, struct device_node
>*of);
>> > +};
>> > +
>> > static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
>> > {
>> > return ioread8(priv->reg_base + reg);
>> > @@ -154,7 +159,8 @@ static void sp_populate_of(struct sja1000_priv
>*priv, struct device_node *of)
>> > priv->cdr |= CDR_CBP; /* default */
>> > }
>> >
>> > -static int sp_probe(struct platform_device *pdev)
>> > +static int __sp_probe(struct platform_device *pdev,
>> > + const struct sja1000_of_data *of_data)
>> > {
>> > int err, irq = 0;
>> > void __iomem *addr;
>> > @@ -163,6 +169,7 @@ static int sp_probe(struct platform_device
>*pdev)
>> > struct resource *res_mem, *res_irq = NULL;
>> > struct sja1000_platform_data *pdata;
>> > struct device_node *of = pdev->dev.of_node;
>> > + size_t priv_sz = of_data ? of_data->priv_sz : 0;
>> >
>> > pdata = dev_get_platdata(&pdev->dev);
>> > if (!pdata && !of) {
>> > @@ -191,7 +198,7 @@ static int sp_probe(struct platform_device
>*pdev)
>> > if (!irq && !res_irq)
>> > return -ENODEV;
>> >
>> > - dev = alloc_sja1000dev(0);
>> > + dev = alloc_sja1000dev(priv_sz);
>> > if (!dev)
>> > return -ENOMEM;
>> > priv = netdev_priv(dev);
>> > @@ -213,6 +220,12 @@ static int sp_probe(struct platform_device
>*pdev)
>> > else
>> > sp_populate(priv, pdata, res_mem->flags);
>> >
>> > + if (of_data && of_data->init) {
>> > + err = of_data->init(priv, of);
>> > + if (err)
>> > + goto exit_free;
>> > + }
>> > +
>> > platform_set_drvdata(pdev, dev);
>> > SET_NETDEV_DEV(dev, &pdev->dev);
>> >
>> > @@ -248,6 +261,28 @@ static const struct of_device_id sp_of_table[]
>= {
>> > };
>> > MODULE_DEVICE_TABLE(of, sp_of_table);
>> >
>> > +static const struct sja1000_of_data *sp_get_of_data(struct
>device_node *of)
>> > +{
>> > + const struct of_device_id *id;
>> > +
>> > + if (!of)
>> > + return NULL;
>> > +
>> > + id = of_match_node(sp_of_table, of);
>> > + if (!id)
>> > + return NULL;
>> > +
>> > + return id->data;
>> > +}
>> > +
>> > +static int sp_probe(struct platform_device *pdev)
>> > +{
>> > + struct device_node *of = pdev->dev.of_node;
>> > + const struct sja1000_of_data *of_data = sp_get_of_data(of);
>> > +
>> > + return __sp_probe(pdev, of_data);
>> > +}
>>
>> Please merge these two into the original sp_probe function, as there
>> already is a test for pdev->dev.of_node.
>
>Ok. sp_get_of_data makes use of sp_of_table, so either I move sp_probe
>below sp_of_table, or I use a forward declaration. Which one do you
>prefer?
Please move sp_of_table.
Marc
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] can: sja1000: add documentation for Technologic Systems version
2015-12-24 17:42 [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
2015-12-24 17:42 ` [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook Damien Riegel
@ 2015-12-24 17:42 ` Damien Riegel
2015-12-24 17:42 ` [PATCH v2 3/3] can: sja1000: of: add compatibility with " Damien Riegel
2016-01-11 16:58 ` [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
3 siblings, 0 replies; 11+ messages in thread
From: Damien Riegel @ 2015-12-24 17:42 UTC (permalink / raw)
To: linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, Marc Kleine-Budde, kernel, Damien Riegel
This commit adds documentation for the Technologic Systems version of
SJA1000. The difference with the NXP version is in the way the registers
are accessed.
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
Documentation/devicetree/bindings/net/can/sja1000.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/can/sja1000.txt b/Documentation/devicetree/bindings/net/can/sja1000.txt
index b4a6d53..ac3160e 100644
--- a/Documentation/devicetree/bindings/net/can/sja1000.txt
+++ b/Documentation/devicetree/bindings/net/can/sja1000.txt
@@ -2,7 +2,7 @@ Memory mapped SJA1000 CAN controller from NXP (formerly Philips)
Required properties:
-- compatible : should be "nxp,sja1000".
+- compatible : should be one of "nxp,sja1000", "technologic,sja1000".
- reg : should specify the chip select, address offset and size required
to map the registers of the SJA1000. The size is usually 0x80.
@@ -14,6 +14,7 @@ Optional properties:
- reg-io-width : Specify the size (in bytes) of the IO accesses that
should be performed on the device. Valid value is 1, 2 or 4.
+ This property is ignored for technologic version.
Default to 1 (8 bits).
- nxp,external-clock-frequency : Frequency of the external oscillator
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] can: sja1000: of: add compatibility with Technologic Systems version
2015-12-24 17:42 [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
2015-12-24 17:42 ` [PATCH v2 1/3] can: sja1000: of: add per-compatible init hook Damien Riegel
2015-12-24 17:42 ` [PATCH v2 2/3] can: sja1000: add documentation for Technologic Systems version Damien Riegel
@ 2015-12-24 17:42 ` Damien Riegel
2016-01-12 7:55 ` Marc Kleine-Budde
2016-01-11 16:58 ` [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
3 siblings, 1 reply; 11+ messages in thread
From: Damien Riegel @ 2015-12-24 17:42 UTC (permalink / raw)
To: linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, Marc Kleine-Budde, kernel, Damien Riegel
Technologic Systems provides an IP compatible with the SJA1000,
instantiated in an FPGA. Because of some bus widths issue, access to
registers is made through a "window" that works like this:
base + 0x0: address to read/write
base + 0x2: 8-bit register value
This commit adds a new compatible device, "technologic,sja1000", with
read and write functions using the window mechanism.
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
drivers/net/can/sja1000/sja1000_platform.c | 47 ++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index e0572d0..bfb124d 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -45,6 +45,10 @@ struct sja1000_of_data {
int (*init)(struct sja1000_priv *priv, struct device_node *of);
};
+struct technologic_priv {
+ spinlock_t io_lock;
+};
+
static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
{
return ioread8(priv->reg_base + reg);
@@ -75,6 +79,43 @@ static void sp_write_reg32(const struct sja1000_priv *priv, int reg, u8 val)
iowrite8(val, priv->reg_base + reg * 4);
}
+static u8 technologic_read_reg16(const struct sja1000_priv *priv, int reg)
+{
+ struct technologic_priv *tp = priv->priv;
+ unsigned long flags;
+ u8 val;
+
+ spin_lock_irqsave(&tp->io_lock, flags);
+ iowrite16(reg, priv->reg_base + 0);
+ val = ioread16(priv->reg_base + 2);
+ spin_unlock_irqrestore(&tp->io_lock, flags);
+
+ return val;
+}
+
+static void technologic_write_reg16(const struct sja1000_priv *priv,
+ int reg, u8 val)
+{
+ struct technologic_priv *tp = priv->priv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&tp->io_lock, flags);
+ iowrite16(reg, priv->reg_base + 0);
+ iowrite16(val, priv->reg_base + 2);
+ spin_unlock_irqrestore(&tp->io_lock, flags);
+}
+
+static int technologic_init(struct sja1000_priv *priv, struct device_node *of)
+{
+ struct technologic_priv *tp = priv->priv;
+
+ priv->read_reg = technologic_read_reg16;
+ priv->write_reg = technologic_write_reg16;
+ spin_lock_init(&tp->io_lock);
+
+ return 0;
+}
+
static void sp_populate(struct sja1000_priv *priv,
struct sja1000_platform_data *pdata,
unsigned long resource_mem_flags)
@@ -255,8 +296,14 @@ static int sp_remove(struct platform_device *pdev)
return 0;
}
+struct sja1000_of_data technologic_data = {
+ .priv_sz = sizeof(struct technologic_priv),
+ .init = technologic_init,
+};
+
static const struct of_device_id sp_of_table[] = {
{.compatible = "nxp,sja1000"},
+ {.compatible = "technologic,sja1000", .data = &technologic_data},
{},
};
MODULE_DEVICE_TABLE(of, sp_of_table);
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] can: sja1000: of: add compatibility with Technologic Systems version
2015-12-24 17:42 ` [PATCH v2 3/3] can: sja1000: of: add compatibility with " Damien Riegel
@ 2016-01-12 7:55 ` Marc Kleine-Budde
2016-01-12 15:51 ` Damien Riegel
0 siblings, 1 reply; 11+ messages in thread
From: Marc Kleine-Budde @ 2016-01-12 7:55 UTC (permalink / raw)
To: Damien Riegel, linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, kernel
[-- Attachment #1: Type: text/plain, Size: 678 bytes --]
On 12/24/2015 06:42 PM, Damien Riegel wrote:
> Technologic Systems provides an IP compatible with the SJA1000,
> instantiated in an FPGA. Because of some bus widths issue, access to
> registers is made through a "window" that works like this:
>
> base + 0x0: address to read/write
> base + 0x2: 8-bit register value
Why do you use io{read,write}16 if it's a 8 bit register?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] can: sja1000: of: add compatibility with Technologic Systems version
2016-01-12 7:55 ` Marc Kleine-Budde
@ 2016-01-12 15:51 ` Damien Riegel
0 siblings, 0 replies; 11+ messages in thread
From: Damien Riegel @ 2016-01-12 15:51 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-kernel, netdev, linux-can, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala, Wolfgang Grandegger,
kernel
On Tue, Jan 12, 2016 at 08:55:38AM +0100, Marc Kleine-Budde wrote:
> On 12/24/2015 06:42 PM, Damien Riegel wrote:
> > Technologic Systems provides an IP compatible with the SJA1000,
> > instantiated in an FPGA. Because of some bus widths issue, access to
> > registers is made through a "window" that works like this:
> >
> > base + 0x0: address to read/write
> > base + 0x2: 8-bit register value
>
> Why do you use io{read,write}16 if it's a 8 bit register?
8-bit is at the IP level, but the bus between the SoC and the FPGA only
supports 16-bit wide access. The point of the window is to convert
between 16-bit and 8-bit access.
Damien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] can: sja1000: support for technologic version
2015-12-24 17:42 [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
` (2 preceding siblings ...)
2015-12-24 17:42 ` [PATCH v2 3/3] can: sja1000: of: add compatibility with " Damien Riegel
@ 2016-01-11 16:58 ` Damien Riegel
2016-01-12 7:56 ` Marc Kleine-Budde
3 siblings, 1 reply; 11+ messages in thread
From: Damien Riegel @ 2016-01-11 16:58 UTC (permalink / raw)
To: linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, Marc Kleine-Budde, kernel
Hi Marc,
On Thu, Dec 24, 2015 at 12:42:50PM -0500, Damien Riegel wrote:
> This patchset introduces support for the technologic version of the
> SJA1000. Access to IP's registers are proxied through a window,
> requiring two bus accesses to read or write a register. These accesses
> must be protected by a spinlock to prevent race conditions. Currently,
> there is no easy way to allocate and initialize this spinlock.
>
> SJA1000 already provides a way to allocate private data, but
> sja1000_platform.c makes no use of it.
>
> Patch 1 adds the capability to allocate and initialize private data on a
> per-compatible basis in sja1000_platform.c.
>
> Patch 2 updates device tree documentation to add the technologic
> version.
>
> Patch 3 updates the driver to implement the technologic version
>
Did you have a chance to take a look at this patchset? I would
appreciate your feedback, especially on the first patch.
Thanks,
Damien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] can: sja1000: support for technologic version
2016-01-11 16:58 ` [PATCH v2 0/3] can: sja1000: support for technologic version Damien Riegel
@ 2016-01-12 7:56 ` Marc Kleine-Budde
0 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2016-01-12 7:56 UTC (permalink / raw)
To: Damien Riegel, linux-kernel, netdev, linux-can
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Wolfgang Grandegger, kernel
[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]
On 01/11/2016 05:58 PM, Damien Riegel wrote:
> Hi Marc,
>
> On Thu, Dec 24, 2015 at 12:42:50PM -0500, Damien Riegel wrote:
>> This patchset introduces support for the technologic version of the
>> SJA1000. Access to IP's registers are proxied through a window,
>> requiring two bus accesses to read or write a register. These accesses
>> must be protected by a spinlock to prevent race conditions. Currently,
>> there is no easy way to allocate and initialize this spinlock.
>>
>> SJA1000 already provides a way to allocate private data, but
>> sja1000_platform.c makes no use of it.
>>
>> Patch 1 adds the capability to allocate and initialize private data on a
>> per-compatible basis in sja1000_platform.c.
>>
>> Patch 2 updates device tree documentation to add the technologic
>> version.
>>
>> Patch 3 updates the driver to implement the technologic version
>>
>
> Did you have a chance to take a look at this patchset? I would
> appreciate your feedback, especially on the first patch.
Done. 2/3 is ok. For the others see my comments.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread