summaryrefslogtreecommitdiffstats
path: root/drivers/net/can/flexcan.c
Commit message (Collapse)AuthorAgeFilesLines
* flexcan: disable bus error interrupts for the i.MX28Wolfgang Grandegger2012-10-011-10/+19
| | | | | | | | | | | | | | | | | | | | Due to a bug in most Flexcan cores, the bus error interrupt needs to be enabled. Otherwise we don't get any error warning or passive interrupts. This is _not_ necessary for the i.MX28 and this patch disables bus error interrupts if "berr-reporting" is not requested. This avoids bus error flooding, which might harm, especially on low-end systems. To handle such quirks of the Flexcan cores, a hardware feature flag has been introduced, also replacing the "hw_ver" variable. So far nobody could tell what Flexcan core version is available on what Freescale SOC, apart from the i.MX6Q and P1010, and which bugs or features are present on the various "hw_rev". CC: Hui Wang <jason77.wang@gmail.com> CC: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* can: flexcan: add 2nd clock to support imx53 and newerSteffen Trumtrar2012-07-201-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for a second clock to the flexcan driver. On modern freescale ARM cores like the imx53 and imx6q two clocks ("ipg" and "per") must be enabled in order to access the CAN core. In the original driver, the clock was requested without specifying the connection id, further all mainline ARM archs with flexcan support (imx28, imx25, imx35) register their flexcan clock without a connection id, too. This patch first renames the existing clk variable to clk_ipg and converts it to devm for easier error handling. The connection id "ipg" is added to the devm_clk_get() call. Then a second clock "per" is requested. As all archs don't specify a connection id, both clk_get return the same clock. This ensures compatibility to existing flexcan support and adds support for imx53 at the same time. After this patch hits mainline, the archs may give their existing flexcan clock the "ipg" connection id and implement a dummy "per" clock. This patch has been tested on imx28 (unmodified clk tree) and on imx53 with a seperate "ipg" and "per" clock. Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Acked-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* can: mark bittiming_const pointer in struct can_priv as constMarc Kleine-Budde2012-07-201-1/+1
| | | | | | | | This patch marks the bittiming_const pointer as in the struct can_pric as "const". This allows us to mark the struct can_bittiming_const in the CAN drivers as "const", too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* can: flexcan: make flexcan_priv.devtype_data member point to const dataMarc Kleine-Budde2012-07-171-2/+2
| | | | | Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* can: flexcan: add hardware controller version supportHui Wang2012-07-031-8/+52
| | | | | | | | | | | | | | | | | | | | | | | | At least in the i.MX series, the flexcan contrller divides into ver_3 and ver_10, current driver is for ver_3 controller. i.MX6 has ver_10 controller, it has more reigsters than ver_3 has. The rxfgmask (Rx FIFO Global Mask) register is one of the new added. Its reset value is 0xffffffff, this means ID Filter Table must be checked when receive a packet, but the driver is designed to accept everything during the chip start, we need to clear this register to follow this design. Use the data entry of the struct of_device_id to point chip specific info, we can set hardware version for each platform. Cc: linux-can@vger.kernel.org Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Hui Wang <jason77.wang@gmail.com> [mkl: add id_table support] Tested-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* can: flexcan: use of_property_read_u32 to get DT entry valueHui Wang2012-07-021-8/+3
| | | | | | | | | | | | | | | of_property_read_u32() can auto handle endian problems, use this function can make code clean and simple. No need to check return value here since the following got value check will handle this. Cc: linux-can@vger.kernel.org Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller2012-06-281-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: drivers/net/caif/caif_hsi.c drivers/net/usb/qmi_wwan.c The qmi_wwan merge was trivial. The caif_hsi.c, on the other hand, was not. It's a conflict between 1c385f1fdf6f9c66d982802cd74349c040980b50 ("caif-hsi: Replace platform device with ops structure.") in the net-next tree and commit 39abbaef19cd0a30be93794aa4773c779c3eb1f3 ("caif-hsi: Postpone init of HIS until open()") in the net tree. I did my best with that one and will ask Sjur to check it out. Signed-off-by: David S. Miller <davem@davemloft.net>
| * can: flexcan: use be32_to_cpup to handle the value of dt entryHui Wang2012-06-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The freescale arm i.MX series platform can support this driver, and usually the arm cpu works in the little endian mode by default, while device tree entry value is stored in big endian format, we should use be32_to_cpup() to handle them, after modification, it can work well both on the le cpu and be cpu. Cc: stable <stable@vger.kernel.org> # v3.2+ Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | Merge branch 'master' of git://gitorious.org/linux-can/linux-can-nextDavid S. Miller2012-06-061-0/+38
|\ \ | |/ |/|
| * can: flexcan: add PM supportEric Bénard2012-05-231-0/+38
| | | | | | | | | | | | | | tested on an i.MX257 Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: adopt pinctrl supportShawn Guo2012-05-121-0/+6
|/ | | | | | | Cc: linux-can@vger.kernel.org Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
* Merge branch 'master' of git://gitorious.org/linux-can/linux-can-nextDavid S. Miller2012-02-041-33/+28
|\ | | | | | | | | | | | | Conflicts: drivers/net/can/usb/ems_usb.c Minor dev_warn --> netdev_warn conversion conflicts.
| * can: replace the dev_dbg/info/err/... with the new netdev_xxx macrosWolfgang Grandegger2012-02-031-23/+21
| | | | | | | | | | | | | | | | | | | | | | | | Cc: uclinux-dist-devel@blackfin.uclinux.org Cc: Anant Gole <anantgole@ti.com> Cc: Chris Elston <celston@katalix.com> Cc: Sebastian Haas <haas@ems-wuensche.com> Cc: Matthias Fuchs <matthias.fuchs@esd.eu> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Sebastian Haas <dev@sebastianhaas.info> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACKReuben Dowle2012-02-031-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the flexcan driver uses hardware local echo. This blindly echos all transmitted frames to all receiving sockets, regardless what CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK are set to. This patch now submits transmitted frames to be echoed in the transmit complete interrupt, preserving the reference to the sending socket. This allows the can protocol to correctly handle the local echo. Further this patch moves tx_bytes statistic accounting into the tx_complete handler. Signed-off-by: Reuben Dowle <reuben.dowle@navico.com> [mkl: move tx_bytes accounting into tx_complete handler; cleanups] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: fix irq flooding by clearing all interrupt sourcesWolfgang Grandegger2012-02-031-1/+6
|/ | | | | | | | | | | | | | As pointed out by Reuben Dowle and Lothar Waßmann, the TWRN_INT, RWRN_INT, BOFF_INT interrupt sources need to be cleared as well to avoid interrupt flooding, at least for the Flexcan on i.MX28 SOCs. Furthermore, the interrupts are only cleared, if really one of those interrupt sources are pending (which is not the case for rx and tx done). Cc: Reuben Dowle <Reuben.Dowle@navico.com> Cc: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* Merge tag 'clk' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-socLinus Torvalds2012-01-091-5/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clock management changes for i.MX Another simple series related to clock management, this time only for imx. * tag 'clk' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: ARM: mxs: select HAVE_CLK_PREPARE for clock clk: add config option HAVE_CLK_PREPARE into Kconfig ASoC: mxs-saif: convert to clk_prepare/clk_unprepare video: mxsfb: convert to clk_prepare/clk_unprepare serial: mxs-auart: convert to clk_prepare/clk_unprepare net: flexcan: convert to clk_prepare/clk_unprepare mtd: gpmi-lib: convert to clk_prepare/clk_unprepare mmc: mxs-mmc: convert to clk_prepare/clk_unprepare dma: mxs-dma: convert to clk_prepare/clk_unprepare net: fec: add clk_prepare/clk_unprepare ARM: mxs: convert platform code to clk_prepare/clk_unprepare clk: add helper functions clk_prepare_enable and clk_disable_unprepare Fix up trivial conflicts in drivers/net/ethernet/freescale/fec.c due to commit 0ebafefcaa7a ("net: fec: add clk_prepare/clk_unprepare") clashing trivially with commit e163cc97f9ac ("net/fec: fix the .remove code").
| * net: flexcan: convert to clk_prepare/clk_unprepareShawn Guo2011-12-281-5/+5
| | | | | | | | | | | | | | | | | | The patch converts flexcan driver to clk_prepare/clk_unprepare by using helper functions clk_prepare_enable/clk_disable_unprepare. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: David S. Miller <davem@davemloft.net>
* | net/can: convert drivers/net/can/* to use module_platform_driver()Axel Lin2011-11-291-14/+1
|/ | | | | | | | | | | | | | | | | | | This patch converts the drivers in drivers/net/can/* to use the module_platform_driver() macro which makes the code smaller and a bit simpler. Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Bhupesh Sharma <bhupesh.sharma@st.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Anatolij Gustschin <agust@denx.de> Cc: Paul Bolle <pebolle@tiscali.nl> Cc: Kurt Van Dijck <kurt.van.dijck@eia.be> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
* flexcan: Prefer device tree clock frequency if available.holt@sgi.com2011-08-171-9/+25
| | | | | | | | | | | | | | | | | | | | If our CAN device's device tree node has a clock-frequency property, then use that value for the can devices clock frequency. If not, fall back to asking the platform/mach code for the clock frequency associated with the flexcan device. Signed-off-by: Robin Holt <holt@sgi.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com>, Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Marc Kleine-Budde <mkl@pengutronix.de>, Cc: U Bhaskar-B22300 <B22300@freescale.com> Cc: Scott Wood <scottwood@freescale.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: socketcan-core@lists.berlios.de, Cc: netdev@vger.kernel.org, Cc: PPC list <linuxppc-dev@lists.ozlabs.org> Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: David S. Miller <davem@davemloft.net>
* flexcan: Add of_match to platform_device definition.holt@sgi.com2011-08-171-1/+12
| | | | | | | | | | | | | | | | | On powerpc, the OpenFirmware devices are not matched without specifying an of_match array. Introduce that array as that is used for matching on the Freescale P1010 processor. Signed-off-by: Robin Holt <holt@sgi.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: U Bhaskar-B22300 <B22300@freescale.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: socketcan-core@lists.berlios.de Cc: netdev@vger.kernel.org Cc: PPC list <linuxppc-dev@lists.ozlabs.org> Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: David S. Miller <davem@davemloft.net>
* flexcan: Abstract off read/write for big/little endian.holt@sgi.com2011-08-171-57/+83
| | | | | | | | | | | | | | Make flexcan driver handle register reads in the appropriate endianess. This was a basic search and replace and then define some inlines. Signed-off-by: Robin Holt <holt@sgi.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: U Bhaskar-B22300 <B22300@freescale.com> Cc: socketcan-core@lists.berlios.de Cc: netdev@vger.kernel.org Cc: PPC list <linuxppc-dev@lists.ozlabs.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* flexcan: Remove #include <mach/clock.h>holt@sgi.com2011-08-171-2/+0
| | | | | | | | | | | | | | powerpc does not have a mach-####/clock.h. When testing, I found neither arm nor powerpc needed the mach/clock.h at all so I removed it. Signed-off-by: Robin Holt <holt@sgi.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: U Bhaskar-B22300 <B22300@freescale.com> Cc: socketcan-core@lists.berlios.de Cc: netdev@vger.kernel.org Cc: PPC list <linuxppc-dev@lists.ozlabs.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* drivers/net/can/flexcan.c: add missing clk_putJulia Lawall2011-06-021-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The failed_get label is used after the call to clk_get has succeeded, so it should be moved up above the call to clk_put. The failed_req labels doesn't do anything different than failed_get, so delete it. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r exists@ expression e1,e2; statement S; @@ e1 = clk_get@p1(...); ... when != e1 = e2 when != clk_put(e1) when any if (...) { ... when != clk_put(e1) when != if (...) { ... clk_put(e1) ... } * return@p3 ...; } else S // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
* can: flexcan: fix use after free of privMarc Kleine-Budde2010-10-261-1/+2
| | | | | | | | The priv is part of the memory allocated by alloc_candev(). This patch moved the free it after last usage of priv. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
* CAN: Add Flexcan CAN controller driverMarc Kleine-Budde2010-07-221-0/+1030
This core is found on some Freescale SoCs and also some Coldfire SoCs. Support for Coldfire is missing though at the moment as they have an older revision of the core which does not have RX FIFO support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>