* [PATCH 0/2] flexcan driver updates
@ 2012-06-26 8:49 Shawn Guo
2012-06-26 8:49 ` [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe Shawn Guo
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Shawn Guo @ 2012-06-26 8:49 UTC (permalink / raw)
To: David S. Miller; +Cc: Marc Kleine-Budde, netdev, linux-arm-kernel, Shawn Guo
Here are a couple of flexcan driver/bindings updates, which are meant
to get the driver more device tree friendly.
Shawn Guo (2):
net: flexcan: clock-frequency is optional for device tree probe
net: flexcan: add transceiver switch gpio support
.../devicetree/bindings/net/can/fsl-flexcan.txt | 6 ++++
drivers/net/can/flexcan.c | 30 ++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe 2012-06-26 8:49 [PATCH 0/2] flexcan driver updates Shawn Guo @ 2012-06-26 8:49 ` Shawn Guo 2012-06-27 8:47 ` Marc Kleine-Budde 2012-06-26 8:49 ` [PATCH 2/2] net: flexcan: add transceiver switch gpio support Shawn Guo 2012-06-26 16:55 ` [PATCH 0/2] flexcan driver updates Oliver Hartkopp 2 siblings, 1 reply; 8+ messages in thread From: Shawn Guo @ 2012-06-26 8:49 UTC (permalink / raw) To: David S. Miller; +Cc: Marc Kleine-Budde, netdev, linux-arm-kernel, Shawn Guo The property clock-frequency is optional for device tree probe. When it's absent, the flexcan driver will try to get the frequency from clk system by calling clk_get_rate. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> --- .../devicetree/bindings/net/can/fsl-flexcan.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt index f31b686..8ff324e 100644 --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt @@ -11,6 +11,9 @@ Required properties: - reg : Offset and length of the register set for this device - interrupts : Interrupt tuple for this device + +Optional properties: + - clock-frequency : The oscillator frequency driving the flexcan device Example: -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe 2012-06-26 8:49 ` [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe Shawn Guo @ 2012-06-27 8:47 ` Marc Kleine-Budde 2012-06-27 8:56 ` Shawn Guo 0 siblings, 1 reply; 8+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 8:47 UTC (permalink / raw) To: Shawn Guo; +Cc: David S. Miller, netdev, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 1406 bytes --] On 06/26/2012 10:49 AM, Shawn Guo wrote: > The property clock-frequency is optional for device tree probe. When > it's absent, the flexcan driver will try to get the frequency from clk > system by calling clk_get_rate. > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> As Oliver pointed out, this doesn't go through the net tree. Marc > --- > .../devicetree/bindings/net/can/fsl-flexcan.txt | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > index f31b686..8ff324e 100644 > --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > @@ -11,6 +11,9 @@ Required properties: > > - reg : Offset and length of the register set for this device > - interrupts : Interrupt tuple for this device > + > +Optional properties: > + > - clock-frequency : The oscillator frequency driving the flexcan device > > Example: -- 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: 262 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe 2012-06-27 8:47 ` Marc Kleine-Budde @ 2012-06-27 8:56 ` Shawn Guo 2012-06-27 8:59 ` Marc Kleine-Budde 0 siblings, 1 reply; 8+ messages in thread From: Shawn Guo @ 2012-06-27 8:56 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: netdev, David S. Miller, linux-arm-kernel On Wed, Jun 27, 2012 at 10:47:24AM +0200, Marc Kleine-Budde wrote: > On 06/26/2012 10:49 AM, Shawn Guo wrote: > > The property clock-frequency is optional for device tree probe. When > > it's absent, the flexcan driver will try to get the frequency from clk > > system by calling clk_get_rate. > > > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> > Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Thanks. > > As Oliver pointed out, this doesn't go through the net tree. > >From what I have seen, device tree maintainers are generally fine with having binding document updates go through subsystem tree. -- Regards, Shawn ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe 2012-06-27 8:56 ` Shawn Guo @ 2012-06-27 8:59 ` Marc Kleine-Budde 0 siblings, 0 replies; 8+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 8:59 UTC (permalink / raw) To: Shawn Guo; +Cc: David S. Miller, netdev, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 1005 bytes --] On 06/27/2012 10:56 AM, Shawn Guo wrote: > On Wed, Jun 27, 2012 at 10:47:24AM +0200, Marc Kleine-Budde wrote: >> On 06/26/2012 10:49 AM, Shawn Guo wrote: >>> The property clock-frequency is optional for device tree probe. When >>> it's absent, the flexcan driver will try to get the frequency from clk >>> system by calling clk_get_rate. >>> >>> Signed-off-by: Shawn Guo <shawn.guo@linaro.org> >> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> > > Thanks. > >> >> As Oliver pointed out, this doesn't go through the net tree. >> > From what I have seen, device tree maintainers are generally fine with > having binding document updates go through subsystem tree. Okay. Then I'll take that patch. 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: 262 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] net: flexcan: add transceiver switch gpio support 2012-06-26 8:49 [PATCH 0/2] flexcan driver updates Shawn Guo 2012-06-26 8:49 ` [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe Shawn Guo @ 2012-06-26 8:49 ` Shawn Guo 2012-06-26 16:55 ` [PATCH 0/2] flexcan driver updates Oliver Hartkopp 2 siblings, 0 replies; 8+ messages in thread From: Shawn Guo @ 2012-06-26 8:49 UTC (permalink / raw) To: David S. Miller; +Cc: Marc Kleine-Budde, netdev, linux-arm-kernel, Shawn Guo The flexcan driver has function pointer transceiver_switch defined in flexcan_platform_data for platform codes to hook up their transceiver switch implementation. However this does not cope with device tree probe. It's been observed that platforms mostly use gpio to control the switch of flexcan transceiver. The patch adds transceiver switch gpio support into flexcan driver, so that platforms that have transceiver switch controlled by gpio can just define property transceiver-switch-gpios in their device tree, and then device tree boot just works with it. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> --- .../devicetree/bindings/net/can/fsl-flexcan.txt | 3 ++ drivers/net/can/flexcan.c | 30 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt index 8ff324e..5ca91d1 100644 --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt @@ -15,6 +15,9 @@ Required properties: Optional properties: - clock-frequency : The oscillator frequency driving the flexcan device +- transceiver-switch-gpios : Should specify the gpio for transceiver switch +- enable-active-low : Polarity of transceiver switch gpio is active low. + If this property is missing, the default assumed is active high. Example: diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 38c0690..bc47595 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -26,6 +26,7 @@ #include <linux/can/platform/flexcan.h> #include <linux/clk.h> #include <linux/delay.h> +#include <linux/gpio.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/interrupt.h> @@ -34,6 +35,7 @@ #include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_gpio.h> #include <linux/platform_device.h> #include <linux/pinctrl/consumer.h> @@ -180,6 +182,9 @@ struct flexcan_priv { struct clk *clk; struct flexcan_platform_data *pdata; + + int switch_gpio; + bool enable_high; }; static struct can_bittiming_const flexcan_bittiming_const = { @@ -224,6 +229,9 @@ static inline void flexcan_write(u32 val, void __iomem *addr) */ static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on) { + if (gpio_is_valid(priv->switch_gpio)) + gpio_set_value(priv->switch_gpio, priv->enable_high ? on : !on); + if (priv->pdata && priv->pdata->transceiver_switch) priv->pdata->transceiver_switch(on); } @@ -933,6 +941,8 @@ static int __devinit flexcan_probe(struct platform_device *pdev) resource_size_t mem_size; int err, irq; u32 clock_freq = 0; + int switch_gpio = -EINVAL; + bool enable_high = true; pinctrl = devm_pinctrl_get_select_default(&pdev->dev); if (IS_ERR(pinctrl)) @@ -945,6 +955,23 @@ static int __devinit flexcan_probe(struct platform_device *pdev) "clock-frequency", NULL); if (clock_freq_p) clock_freq = *clock_freq_p; + + switch_gpio = of_get_named_gpio(pdev->dev.of_node, + "transceiver-switch-gpios", 0); + if (gpio_is_valid(switch_gpio)) { + err = gpio_request_one(switch_gpio, GPIOF_DIR_OUT, + "transceiver-switch"); + if (err) { + dev_err(&pdev->dev, + "failed to request gpio %d: %d\n", + switch_gpio, err); + goto failed_gpio; + } + + if (of_get_property(pdev->dev.of_node, + "enable-active-low", NULL)) + enable_high = false; + } } if (!clock_freq) { @@ -997,6 +1024,8 @@ static int __devinit flexcan_probe(struct platform_device *pdev) priv->base = base; priv->dev = dev; priv->clk = clk; + priv->switch_gpio = switch_gpio; + priv->enable_high = enable_high; priv->pdata = pdev->dev.platform_data; netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT); @@ -1025,6 +1054,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) if (clk) clk_put(clk); failed_clock: + failed_gpio: return err; } -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] flexcan driver updates 2012-06-26 8:49 [PATCH 0/2] flexcan driver updates Shawn Guo 2012-06-26 8:49 ` [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe Shawn Guo 2012-06-26 8:49 ` [PATCH 2/2] net: flexcan: add transceiver switch gpio support Shawn Guo @ 2012-06-26 16:55 ` Oliver Hartkopp 2012-06-27 0:26 ` Shawn Guo 2 siblings, 1 reply; 8+ messages in thread From: Oliver Hartkopp @ 2012-06-26 16:55 UTC (permalink / raw) To: Shawn Guo; +Cc: David S. Miller, Marc Kleine-Budde, netdev, linux-arm-kernel On 26.06.2012 10:49, Shawn Guo wrote: > Here are a couple of flexcan driver/bindings updates, which are meant > to get the driver more device tree friendly. > > Shawn Guo (2): > net: flexcan: clock-frequency is optional for device tree probe > net: flexcan: add transceiver switch gpio support > > .../devicetree/bindings/net/can/fsl-flexcan.txt | 6 ++++ > drivers/net/can/flexcan.c | 30 ++++++++++++++++++++ > 2 files changed, 36 insertions(+), 0 deletions(-) > Sorry Shawn, but your posting is pretty misplaced ... Please check for the maintainers and mailing lists in the MAINTAINERS file that match your suggested changes: Documentation/devicetree/bindings/net/can/fsl-flexcan.txt => OPEN FIRMWARE AND FLATTENED DEVICE TREE M: Grant Likely <grant.likely@secretlab.ca> M: Rob Herring <rob.herring@calxeda.com> L: devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers) W: http://fdt.secretlab.ca T: git git://git.secretlab.ca/git/linux-2.6.git S: Maintained F: Documentation/devicetree <<<<<------------- !!! F: drivers/of F: include/linux/of*.h K: of_get_property K: of_match_table drivers/net/can/flexcan.c => CAN NETWORK DRIVERS M: Wolfgang Grandegger <wg@grandegger.com> M: Marc Kleine-Budde <mkl@pengutronix.de> L: linux-can@vger.kernel.org W: http://gitorious.org/linux-can T: git git://gitorious.org/linux-can/linux-can-next.git S: Maintained F: drivers/net/can/ <<<<<------------- !!! F: include/linux/can/dev.h F: include/linux/can/error.h F: include/linux/can/netlink.h F: include/linux/can/platform/ So please post your suggested changes for the flexcan driver on the mailing lists linux-can@vger.kernel.org and devicetree-discuss@lists.ozlabs.org Once the changes are discussed and accepted they can be pulled by Dave Miller from the CAN development git repository into the networking tree. Thanks, Oliver ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] flexcan driver updates 2012-06-26 16:55 ` [PATCH 0/2] flexcan driver updates Oliver Hartkopp @ 2012-06-27 0:26 ` Shawn Guo 0 siblings, 0 replies; 8+ messages in thread From: Shawn Guo @ 2012-06-27 0:26 UTC (permalink / raw) To: Oliver Hartkopp Cc: David S. Miller, Marc Kleine-Budde, netdev, linux-arm-kernel On 27 June 2012 00:55, Oliver Hartkopp <socketcan@hartkopp.net> wrote: > So please post your suggested changes for the flexcan driver on the mailing > lists linux-can@vger.kernel.org and devicetree-discuss@lists.ozlabs.org > Yes, you are right. Will resend. Thanks. Regards, Shawn ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-06-27 8:59 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-26 8:49 [PATCH 0/2] flexcan driver updates Shawn Guo 2012-06-26 8:49 ` [PATCH 1/2] net: flexcan: clock-frequency is optional for device tree probe Shawn Guo 2012-06-27 8:47 ` Marc Kleine-Budde 2012-06-27 8:56 ` Shawn Guo 2012-06-27 8:59 ` Marc Kleine-Budde 2012-06-26 8:49 ` [PATCH 2/2] net: flexcan: add transceiver switch gpio support Shawn Guo 2012-06-26 16:55 ` [PATCH 0/2] flexcan driver updates Oliver Hartkopp 2012-06-27 0:26 ` Shawn Guo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).