Hello,
Changes sinces v1:
- Merge sja1000_of_platform.c into sja1000_platform.c (patch 4)
The first part of this series performs serveral small cleanups
(patches 1 to 3).
Patch 4 merges sja1000_of_platform.c into sja1000_platform.c.
Changes are pretty conservatives (mostly copy/paste/move). IRQ
is treated differently in the OF and non-OF versions, thus this
is where the fused version differs the most.
The final part introduces the 'reg-io-width' binding (already used
by some other drivers) to perform a similar job as what was done
with IORESOURCE_MEM_XXBIT. This is needed on my system to correctly
take into account the aliasing of the address bus.
All patches were tested using OF boot on my OMAP3 system with a
memory-mapped SJA1000. Thus, the non-OF path is not tested, as
I do not have a platform data at hand.
Regards,
Florian
Florian Vaussard (6):
can: sja1000: remove unused defines
can: sja1000: convert printk to use netdev API
can: sja1000: platform: use devm_* APIs
can: sja1000: fuse of_platform into platform
Documentation: devicetree: sja1000: add reg-io-width binding
can: sja1000: of: add reg-io-width property for 8, 16 and 32-bit
register access
.../devicetree/bindings/net/can/sja1000.txt | 4 +
drivers/net/can/sja1000/Kconfig | 13 +-
drivers/net/can/sja1000/Makefile | 1 -
drivers/net/can/sja1000/sja1000.c | 3 +-
drivers/net/can/sja1000/sja1000_of_platform.c | 221 ---------------------
drivers/net/can/sja1000/sja1000_platform.c | 194 ++++++++++++------
6 files changed, 141 insertions(+), 295 deletions(-)
delete mode 100644 drivers/net/can/sja1000/sja1000_of_platform.c
--
1.8.1.2
@@ -12,6 +12,10 @@ Required properties: 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.+ Default to 1 (8 bits).+ - nxp,external-clock-frequency : Frequency of the external oscillator clock in Hz. Note that the internal clock frequency used by the SJA1000 is half of that value. If not specified, a default value
Add the 'reg-io-width' property for 8, 16 and 32-bit access, like
what is currently done with IORESOURCE_MEM_{8,16,32}BIT for non-OF
boot.
Signed-off-by: Florian Vaussard <redacted>
---
drivers/net/can/sja1000/sja1000_platform.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
@@ -27,12 +27,16 @@#include<linux/can/dev.h>#include<linux/can/platform/sja1000.h>#include<linux/io.h>+#include<linux/of.h>+#include<linux/of_irq.h>#include"sja1000.h"#define DRV_NAME "sja1000_platform"+#define SJA1000_OFP_CAN_CLOCK (16000000 / 2)MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");+MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");MODULE_ALIAS("platform:"DRV_NAME);MODULE_LICENSE("GPL v2");
@@ -67,24 +71,98 @@ static void sp_write_reg32(const struct sja1000_priv *priv, int reg, u8 val)iowrite8(val,priv->reg_base+reg*4);}-staticintsp_probe(structplatform_device*pdev)+staticvoidsp_populate(structsja1000_priv*priv,+structsja1000_platform_data*pdata,+unsignedlongresource_mem_flags)+{+/* The CAN clock frequency is half the oscillator clock frequency */+priv->can.clock.freq=pdata->osc_freq/2;+priv->ocr=pdata->ocr;+priv->cdr=pdata->cdr;++switch(resource_mem_flags&IORESOURCE_MEM_TYPE_MASK){+caseIORESOURCE_MEM_32BIT:+priv->read_reg=sp_read_reg32;+priv->write_reg=sp_write_reg32;+break;+caseIORESOURCE_MEM_16BIT:+priv->read_reg=sp_read_reg16;+priv->write_reg=sp_write_reg16;+break;+caseIORESOURCE_MEM_8BIT:+default:+priv->read_reg=sp_read_reg8;+priv->write_reg=sp_write_reg8;+break;+}+}++#if defined(CONFIG_OF)+staticvoidsp_populate_of(structsja1000_priv*priv,structdevice_node*of){interr;+u32prop;++priv->read_reg=sp_read_reg8;+priv->write_reg=sp_write_reg8;++err=of_property_read_u32(of,"nxp,external-clock-frequency",&prop);+if(!err)+priv->can.clock.freq=prop/2;+else+priv->can.clock.freq=SJA1000_OFP_CAN_CLOCK;/* default */++err=of_property_read_u32(of,"nxp,tx-output-mode",&prop);+if(!err)+priv->ocr|=prop&OCR_MODE_MASK;+else+priv->ocr|=OCR_MODE_NORMAL;/* default */++err=of_property_read_u32(of,"nxp,tx-output-config",&prop);+if(!err)+priv->ocr|=(prop<<OCR_TX_SHIFT)&OCR_TX_MASK;+else+priv->ocr|=OCR_TX0_PULLDOWN;/* default */++err=of_property_read_u32(of,"nxp,clock-out-frequency",&prop);+if(!err&&prop){+u32divider=priv->can.clock.freq*2/prop;++if(divider>1)+priv->cdr|=divider/2-1;+else+priv->cdr|=CDR_CLKOUT_MASK;+}else{+priv->cdr|=CDR_CLK_OFF;/* default */+}++if(!of_property_read_bool(of,"nxp,no-comparator-bypass"))+priv->cdr|=CDR_CBP;/* default */+}+#else+staticvoidsp_populate_of(structsja1000_priv*priv,device_node*of)+{+}+#endif++staticintsp_probe(structplatform_device*pdev)+{+interr,irq=0;void__iomem*addr;structnet_device*dev;structsja1000_priv*priv;-structresource*res_mem,*res_irq;+structresource*res_mem,*res_irq=0;structsja1000_platform_data*pdata;+structdevice_node*of=pdev->dev.of_node;pdata=dev_get_platdata(&pdev->dev);-if(!pdata){+if(!pdata&&!of){dev_err(&pdev->dev,"No platform data provided!\n");return-ENODEV;}res_mem=platform_get_resource(pdev,IORESOURCE_MEM,0);-res_irq=platform_get_resource(pdev,IORESOURCE_IRQ,0);-if(!res_mem||!res_irq)+if(!res_mem)return-ENODEV;if(!devm_request_mem_region(&pdev->dev,res_mem->start,
@@ -96,36 +174,34 @@ static int sp_probe(struct platform_device *pdev)if(!addr)return-ENOMEM;+if(of)+irq=irq_of_parse_and_map(of,0);+else+res_irq=platform_get_resource(pdev,IORESOURCE_IRQ,0);++if(!irq&&!res_irq)+return-ENODEV;+dev=alloc_sja1000dev(0);if(!dev)return-ENOMEM;priv=netdev_priv(dev);-dev->irq=res_irq->start;-priv->irq_flags=res_irq->flags&IRQF_TRIGGER_MASK;-if(res_irq->flags&IORESOURCE_IRQ_SHAREABLE)-priv->irq_flags|=IRQF_SHARED;+if(res_irq){+irq=res_irq->start;+priv->irq_flags=res_irq->flags&IRQF_TRIGGER_MASK;+if(res_irq->flags&IORESOURCE_IRQ_SHAREABLE)+priv->irq_flags|=IRQF_SHARED;+}else+priv->irq_flags=IRQF_SHARED;++dev->irq=irq;priv->reg_base=addr;-/* The CAN clock frequency is half the oscillator clock frequency */-priv->can.clock.freq=pdata->osc_freq/2;-priv->ocr=pdata->ocr;-priv->cdr=pdata->cdr;-switch(res_mem->flags&IORESOURCE_MEM_TYPE_MASK){-caseIORESOURCE_MEM_32BIT:-priv->read_reg=sp_read_reg32;-priv->write_reg=sp_write_reg32;-break;-caseIORESOURCE_MEM_16BIT:-priv->read_reg=sp_read_reg16;-priv->write_reg=sp_write_reg16;-break;-caseIORESOURCE_MEM_8BIT:-default:-priv->read_reg=sp_read_reg8;-priv->write_reg=sp_write_reg8;-break;-}+if(of)+sp_populate_of(priv,of);+else+sp_populate(priv,pdata,res_mem->flags);platform_set_drvdata(pdev,dev);SET_NETDEV_DEV(dev,&pdev->dev);
@@ -156,12 +232,21 @@ static int sp_remove(struct platform_device *pdev)return0;}+#if defined(CONFIG_OF)+staticstructof_device_idsja1000_ofp_table[]={+{.compatible="nxp,sja1000"},+{},+};+MODULE_DEVICE_TABLE(of,sja1000_ofp_table);+#endif+staticstructplatform_driversp_driver={.probe=sp_probe,.remove=sp_remove,.driver={.name=DRV_NAME,.owner=THIS_MODULE,+.of_match_table=of_match_ptr(sja1000_ofp_table),},};
Simplify probe and remove functions by converting most of the resources
to use devm_* APIs.
Signed-off-by: Florian Vaussard <redacted>
---
drivers/net/can/sja1000/sja1000_platform.c | 46 ++++++++----------------------
1 file changed, 12 insertions(+), 34 deletions(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:28:50
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted hunk
Add the 'reg-io-width' property for 8, 16 and 32-bit access, like
what is currently done with IORESOURCE_MEM_{8,16,32}BIT for non-OF
boot.
Signed-off-by: Florian Vaussard <redacted>
---
drivers/net/can/sja1000/sja1000_platform.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:29:44
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
Add the reg-io-width property to describe the width of the memory
accesses.
Cc: Grant Likely <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <redacted>
Cc: Kumar Gala <redacted>
Cc: devicetree@vger.kernel.org
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Florian Vaussard <redacted>
I think it makes sense to squash into patch 6.
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 |
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:33:45
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:35:38
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
Remove unused defines for the OF platform.
Signed-off-by: Florian Vaussard <redacted>
I've overlooked in my first review that this patch is touching the
of_platform driver. Please remove the patch, as we want to remove the
driver sooner or later.
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 |
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:37:33
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
Hello,
Changes sinces v1:
- Merge sja1000_of_platform.c into sja1000_platform.c (patch 4)
The first part of this series performs serveral small cleanups
(patches 1 to 3).
Patch 4 merges sja1000_of_platform.c into sja1000_platform.c.
Changes are pretty conservatives (mostly copy/paste/move). IRQ
is treated differently in the OF and non-OF versions, thus this
is where the fused version differs the most.
The final part introduces the 'reg-io-width' binding (already used
by some other drivers) to perform a similar job as what was done
with IORESOURCE_MEM_XXBIT. This is needed on my system to correctly
take into account the aliasing of the address bus.
Good work, please keep compatibility for DTs without the 'reg-io-width'
binding. The rest of my comments are only nitpicks. :)
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 |
Hello Marc,
On 01/31/2014 01:37 PM, Marc Kleine-Budde wrote:
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
Hello,
Changes sinces v1:
- Merge sja1000_of_platform.c into sja1000_platform.c (patch 4)
The first part of this series performs serveral small cleanups
(patches 1 to 3).
Patch 4 merges sja1000_of_platform.c into sja1000_platform.c.
Changes are pretty conservatives (mostly copy/paste/move). IRQ
is treated differently in the OF and non-OF versions, thus this
is where the fused version differs the most.
The final part introduces the 'reg-io-width' binding (already used
by some other drivers) to perform a similar job as what was done
with IORESOURCE_MEM_XXBIT. This is needed on my system to correctly
take into account the aliasing of the address bus.
Good work, please keep compatibility for DTs without the 'reg-io-width'
binding. The rest of my comments are only nitpicks. :)
Hello Marc,
On 01/31/2014 01:33 PM, Marc Kleine-Budde wrote:
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
Do you have any reason for not deleting of_platform? After this patch,
we will have duplicated functionalities, this may be misleading for
other people.
Regards,
Florian
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:49:49
On 01/31/2014 01:45 PM, Florian Vaussard wrote:
Hello Marc,
On 01/31/2014 01:33 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
Do you have any reason for not deleting of_platform? After this patch,
we will have duplicated functionalities, this may be misleading for
other people.
Okay.
IIRC there _was_ a problem on sparc, it _should_ be fixed now, better
get a Tested-by from Andreas (Cc'ed).
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 |
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 12:51:25
On 01/31/2014 01:49 PM, Marc Kleine-Budde wrote:
On 01/31/2014 01:45 PM, Florian Vaussard wrote:
quoted
Hello Marc,
On 01/31/2014 01:33 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
Do you have any reason for not deleting of_platform? After this patch,
we will have duplicated functionalities, this may be misleading for
other people.
Okay.
IIRC there _was_ a problem on sparc, it _should_ be fixed now, better
get a Tested-by from Andreas (Cc'ed).
You have to use irq_of_parse_and_map() on sparc, but your patches does this.
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 |
Hello Marc,
On 01/31/2014 01:33 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
Do you have any reason for not deleting of_platform? After this patch,
we will have duplicated functionalities, this may be misleading for
other people.
Okay.
IIRC there _was_ a problem on sparc, it _should_ be fixed now, better
get a Tested-by from Andreas (Cc'ed).
So it is ok for you if I remove of_platform, right?
You have to use irq_of_parse_and_map() on sparc, but your patches does this.
My first implementation was not using irq_of_parse_and_map(), as I do
not need it on ARM, but I suspected that other people might need it.
This is why the final code is slightly more complicated to handle both
cases.
Regards,
Florian
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2014-01-31 13:14:22
On 01/31/2014 02:00 PM, Florian Vaussard wrote:
On 01/31/2014 01:51 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 01:49 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 01:45 PM, Florian Vaussard wrote:
quoted
Hello Marc,
On 01/31/2014 01:33 PM, Marc Kleine-Budde wrote:
quoted
On 01/31/2014 11:35 AM, Florian Vaussard wrote:
quoted
The OpenFirmware probe can be merged into the standard platform
probe to leverage common code.
Good work, as we want to replace the existing driver, I'm quite picky on
this patch, see more comments inline.
Please don't delete of of_platform driver, yet.
Do you have any reason for not deleting of_platform? After this patch,
we will have duplicated functionalities, this may be misleading for
other people.
Okay.
IIRC there _was_ a problem on sparc, it _should_ be fixed now, better
get a Tested-by from Andreas (Cc'ed).
So it is ok for you if I remove of_platform, right?
If you get a Tested-by for this patch by a sparc user.
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 |
Add the reg-io-width property to describe the width of the memory
accesses.
Cc: Grant Likely <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <redacted>
Cc: Kumar Gala <redacted>
Cc: devicetree@vger.kernel.org
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Florian Vaussard <redacted>