Add MCAN Support for dra76x
Subsystems (4)
v5 cover Add MCAN Support for dra76x
The following patches add dts and sysconfig support for MCAN on TI's dra76 SOCs
Changes in v5:
Return from sysc_reset() with error if syss_mask is not present. That is the only supported way of reset
Changes in v4:
1. Rebased to latest kernel
2. Using ddata->cfg.syss_mask instead of ddata->cfg.quirks for checking if poll on reset status is required.
Changes in v3:
1. Added reset functionality to the ti-sysc
driver. This enables me to drop the hwmod
data patch as everything is being done in dt.
2. Dropped ti,hwmods from the dts nodes
3. Fixed the unit address of target-module
and mcan
4. Removed the status="disabled" in dtsi
followed by status="okay" in dts.
Changes in v2:
1. Added Support for mcan in the ti-sysc driver Also added the target-module node for the same
2. Added clkctrl data for mcan clocks
Faiz Abbas (5):
clk: ti: dra7: Add clkctrl clock data for the mcan clocks
bus: ti-sysc: Add support for using ti-sysc for MCAN on dra76x
bus: ti-sysc: Add support for software reset
ARM: dts: Add generic interconnect target module node for MCAN
ARM: dts: dra76x: Add MCAN node
Lokesh Vutla (1):
ARM: dts: dra762: Add MCAN clock support
.../devicetree/bindings/bus/ti-sysc.txt | 1 + arch/arm/boot/dts/dra76-evm.dts | 6 ++ arch/arm/boot/dts/dra76x.dtsi | 64 +++++++++++++++++++ drivers/bus/ti-sysc.c | 62 ++++++++++++++++++ drivers/clk/ti/clk-7xx.c | 1 + include/dt-bindings/bus/ti-sysc.h | 2 + include/dt-bindings/clock/dra7.h | 1 + include/linux/platform_data/ti-sysc.h | 1 + 8 files changed, 138 insertions(+)
Signature · 1 line
2.17.0
PATCH v5 1/6 ARM: dts: dra762: Add MCAN clock support
From: Lokesh Vutla <[email protected]>
MCAN is clocked by H14 divider of DPLL_GMAC. Unlike other DPLL dividers this DPLL_GMAC H14 divider is controlled by control module. Adding support for these clocks.
--- arch/arm/boot/dts/dra76x.dtsi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/arm/boot/dts/dra76x.dtsi +33 -0
@@ -17,3 +17,36 @@ &crossbar_mpu { ti,irqs-skip = <10 67 68 133 139 140>; }; + +&scm_conf_clocks { + dpll_gmac_h14x2_ctrl_ck: dpll_gmac_h14x2_ctrl_ck at 3fc { + #clock-cells = <0>; + compatible = "ti,divider-clock"; + clocks = <&dpll_gmac_x2_ck>; + ti,max-div = <63>; + reg = <0x03fc>; + ti,bit-shift=<20>; + ti,latch-bit=<26>; + assigned-clocks = <&dpll_gmac_h14x2_ctrl_ck>; + assigned-clock-rates = <80000000>; + }; + + dpll_gmac_h14x2_ctrl_mux_ck: dpll_gmac_h14x2_ctrl_mux_ck at 3fc { + #clock-cells = <0>; + compatible = "ti,mux-clock"; + clocks = <&dpll_gmac_ck>, <&dpll_gmac_h14x2_ctrl_ck>; + reg = <0x3fc>; + ti,bit-shift = <29>; + ti,latch-bit=<26>; + assigned-clocks = <&dpll_gmac_h14x2_ctrl_mux_ck>; + assigned-clock-parents = <&dpll_gmac_h14x2_ctrl_ck>; + }; + + mcan_clk: mcan_clk at 3fc { + #clock-cells = <0>; + compatible = "ti,gate-clock"; + clocks = <&dpll_gmac_h14x2_ctrl_mux_ck>; + ti,bit-shift = <27>; + reg = <0x3fc>; + }; +};
Signature · 1 line
2.17.0
PATCH v5 2/6 clk: ti: dra7: Add clkctrl clock data for the mcan clocks
In reply to Faiz AbbasAdd clkctrl data for the m_can clocks and register it within the clkctrl driver
--- drivers/clk/ti/clk-7xx.c | 1 + include/dt-bindings/clock/dra7.h | 1 + 2 files changed, 2 insertions(+)
drivers/clk/ti/clk-7xx.c +1 -0
@@ -708,6 +708,7 @@ static const struct omap_clkctrl_reg_data dra7_wkupaon_clkctrl_regs[] __initcons { DRA7_COUNTER_32K_CLKCTRL, NULL, 0, "wkupaon_iclk_mux" }, { DRA7_UART10_CLKCTRL, dra7_uart10_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0060:24" }, { DRA7_DCAN1_CLKCTRL, dra7_dcan1_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0068:24" }, + { DRA7_ADC_CLKCTRL, NULL, CLKF_SW_SUP, "mcan_clk"}, { 0 }, };
include/dt-bindings/clock/dra7.h +1 -0
@@ -168,5 +168,6 @@#define DRA7_COUNTER_32K_CLKCTRL DRA7_CLKCTRL_INDEX(0x50)#define DRA7_UART10_CLKCTRL DRA7_CLKCTRL_INDEX(0x80)#define DRA7_DCAN1_CLKCTRL DRA7_CLKCTRL_INDEX(0x88) +#define DRA7_ADC_CLKCTRL DRA7_CLKCTRL_INDEX(0xa0)#endif
Signature · 1 line
2.17.0
Tony Lindgren
maintainerRe: [PATCH v5 2/6] clk: ti: dra7: Add clkctrl clock data for the mcan clocks
Quoted 2 lines · Faiz Abbas
Add clkctrl data for the
m_canclocks and register it within the clkctrl driver
I'll apply patches 2 to 5 to omap-for-v4.19/ti-sysc. The clock patch is trivial enough to not have to wait for Tero to be back online.
And I'll apply the dts changes into omap-for-v4.19/dt-mcan based on omap-for-v4.19/ti-sysc because of the dependency to the clocks.
Regards,
Tony
PATCH v5 3/6 bus: ti-sysc: Add support for using ti-sysc for MCAN on dra76x
In reply to Faiz AbbasThe dra76x MCAN generic interconnect module has a its own format for the bits in the control registers.
Therefore add a new module type, new regbits and new capabilities specific to the MCAN module.
--- .../devicetree/bindings/bus/ti-sysc.txt | 1 + drivers/bus/ti-sysc.c | 18 ++++++++++++++++++ include/dt-bindings/bus/ti-sysc.h | 2 ++ include/linux/platform_data/ti-sysc.h | 1 + 4 files changed, 22 insertions(+)
Documentation/devicetree/bindings/bus/ti-sysc.txt +1 -0
@@ -36,6 +36,7 @@ Required standard properties: "ti,sysc-omap-aes" "ti,sysc-mcasp" "ti,sysc-usb-host-fs" + "ti,sysc-dra7-mcan" - reg shall have register areas implemented for the interconnect target module in question such as revision, sysc and syss
drivers/bus/ti-sysc.c +18 -0
@@ -1552,6 +1552,23 @@ static const struct sysc_capabilities sysc_omap4_usb_host_fs = { .regbits = &sysc_regbits_omap4_usb_host_fs, }; +static const struct sysc_regbits sysc_regbits_dra7_mcan = { + .dmadisable_shift = -ENODEV , + .midle_shift = -ENODEV , + .sidle_shift = -ENODEV , + .clkact_shift = -ENODEV , + .enwkup_shift =4 , + .srst_shift =0 , + .emufree_shift = -ENODEV , + .autoidle_shift = -ENODEV , +}; + +static const struct sysc_capabilities sysc_dra7_mcan = { + .type =TI_SYSC_DRA7_MCAN , + .sysc_mask =SYSC_DRA7_MCAN_ENAWAKEUP |SYSC_OMAP4_SOFTRESET , + .regbits = &sysc_regbits_dra7_mcan, +}; +static int sysc_init_pdata (struct sysc *ddata) {struct ti_sysc_platform_data *pdata =dev_get_platdata (ddata->dev);
@@ -1743,6 +1760,7 @@ static const struct of_device_id sysc_match[] = { { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, }, { .compatible = "ti,sysc-usb-host-fs", .data = &sysc_omap4_usb_host_fs, }, + { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, }, { }, }; MODULE_DEVICE_TABLE(of, sysc_match);
include/dt-bindings/bus/ti-sysc.h +2 -0
@@ -15,6 +15,8 @@/* SmartReflex sysc found on 36xx and later */ #define SYSC_OMAP3_SR_ENAWAKEUP (1 << 26) +#define SYSC_DRA7_MCAN_ENAWAKEUP (1 << 4) +/* SYSCONFIG STANDBYMODE/MIDLEMODE/SIDLEMODE supported by hardware */ #define SYSC_IDLE_FORCE 0#define SYSC_IDLE_NO 1
include/linux/platform_data/ti-sysc.h +1 -0
@@ -14,6 +14,7 @@ enum ti_sysc_module_type {TI_SYSC_OMAP4_SR ,TI_SYSC_OMAP4_MCASP ,TI_SYSC_OMAP4_USB_HOST_FS , + TI_SYSC_DRA7_MCAN, }; struct ti_sysc_cookie {
Signature · 1 line
2.17.0
PATCH v5 4/6 bus: ti-sysc: Add support for software reset
In reply to Faiz AbbasAdd support for the software reset of a target interconnect module using its sysconfig and sysstatus registers.
--- drivers/bus/ti-sysc.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/bus/ti-sysc.c +44 -0
@@ -23,11 +23,14 @@#include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/slab.h> +#include <linux/iopoll.h> #include <linux/platform_data/ti-sysc.h> #include <dt-bindings/bus/ti-sysc.h> +#define MAX_MODULE_SOFTRESET_WAIT 10000 +static const char *const reg_names[] = {"rev" ,"sysc" ,"syss" , };enum sysc_clocks {
@@ -88,6 +91,11 @@ struct sysc {struct delayed_work idle_work; }; +void sysc_write (struct sysc *ddata,int offset,u32 value) +{ +writel_relaxed (value, ddata->module_va + offset); +} +static u32 sysc_read (struct sysc *ddata,int offset) {if (ddata->cfg.quirks &SYSC_QUIRK_16BIT ) {
@@ -943,6 +951,31 @@ static void sysc_init_revision_quirks(struct sysc *ddata) } } +static int sysc_reset (struct sysc *ddata) +{ +int offset = ddata->offsets[SYSC_SYSCONFIG ]; +int val =sysc_read (ddata, offset); + +/* +* Currently only support reset status in sysstatus. +* Warn and return error in all other cases +*/ +if (!ddata->cfg.syss_mask) { +dev_err (ddata->dev,"No ti,syss-mask. Reset failed\n" ); +return -EINVAL ; + } + + val |= (0x1 << ddata->cap->regbits->srst_shift); +sysc_write (ddata, offset, val); + +/* Poll on reset status */ + offset = ddata->offsets[SYSC_SYSSTATUS ]; + +return readl_poll_timeout (ddata->module_va + offset, val, + (val & ddata->cfg.syss_mask) ==0x0 , +100 ,MAX_MODULE_SOFTRESET_WAIT ); +} +/* At this point the module is configured enough to read the revision */ static int sysc_init_module (struct sysc *ddata) {
@@ -960,6 +993,17 @@ static int sysc_init_module(struct sysc *ddata)return 0 ; } +if (!(ddata->cfg.quirks &SYSC_QUIRK_NO_RESET_ON_INIT ) && + !ddata->legacy_mode) { + error =sysc_reset (ddata); +if (error) { +dev_err (ddata->dev,"Reset failed with %d\n" , error); +pm_runtime_put_sync (ddata->dev); + +return error; + } + } + ddata->revision =sysc_read_revision (ddata);pm_runtime_put_sync (ddata->dev);
Signature · 1 line
2.17.0
Tony Lindgren
maintainerRe: [PATCH v5 4/6] bus: ti-sysc: Add support for software reset
Hi,
Quoted 2 lines · Faiz Abbas
Add support for the software reset of a target interconnect module using its sysconfig and sysstatus registers.
...
Quoted 2 lines
drivers/bus/ti-sysc.c +0
-0
...
drivers/bus/ti-sysc.c
Quoted 4 lines
drivers/bus/ti-sysc.c +4
-0+static int sysc_reset (struct sysc *ddata) +{ +int offset = ddata->offsets[SYSC_SYSCONFIG ]; +int val =sysc_read (ddata, offset);
Testing with omap4 sysc dts data I noticed we already have modules where there is only rev register and no SYSC_SYSCONFIG. So not using legacy mode. The above offset with -ENODEV value will not work :)
I added some more checks and moved them to the reset function.
Updated patch below for reference, I've pushed out new branches omap-for-v4.19/ti-sysc-v2 and omap-for-v4.19/dt-mcan-v2. I've also updated my for-next branch.
Regards,
Tony
8< -----------
Quoted 1 line
From tony Mon Sep 17 00:00:00 2001
From: Faiz Abbas <[email protected]>
Date: Mon, 9 Jul 2018 22:18:39 +0530
Subject: [PATCH] bus: ti-sysc: Add support for software reset
Add support for the software reset of a target interconnect module using its sysconfig and sysstatus registers.
--- drivers/bus/ti-sysc.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/bus/ti-sysc.c +46 -0
@@ -23,11 +23,14 @@#include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/slab.h> +#include <linux/iopoll.h> #include <linux/platform_data/ti-sysc.h> #include <dt-bindings/bus/ti-sysc.h> +#define MAX_MODULE_SOFTRESET_WAIT 10000 +static const char *const reg_names[] = {"rev" ,"sysc" ,"syss" , };enum sysc_clocks {
@@ -88,6 +91,11 @@ struct sysc {struct delayed_work idle_work; }; +void sysc_write (struct sysc *ddata,int offset,u32 value) +{ +writel_relaxed (value, ddata->module_va + offset); +} +static u32 sysc_read (struct sysc *ddata,int offset) {if (ddata->cfg.quirks &SYSC_QUIRK_16BIT ) {
@@ -943,6 +951,36 @@ static void sysc_init_revision_quirks(struct sysc *ddata) } } +static int sysc_reset (struct sysc *ddata) +{ +int offset = ddata->offsets[SYSC_SYSCONFIG ]; +int val; + +if (ddata->legacy_mode || offset <0 || + ddata->cfg.quirks &SYSC_QUIRK_NO_RESET_ON_INIT ) +return 0 ; + +/* +* Currently only support reset status in sysstatus. +* Warn and return error in all other cases +*/ +if (!ddata->cfg.syss_mask) { +dev_err (ddata->dev,"No ti,syss-mask. Reset failed\n" ); +return -EINVAL ; + } + + val =sysc_read (ddata, offset); + val |= (0x1 << ddata->cap->regbits->srst_shift); +sysc_write (ddata, offset, val); + +/* Poll on reset status */ + offset = ddata->offsets[SYSC_SYSSTATUS ]; + +return readl_poll_timeout (ddata->module_va + offset, val, + (val & ddata->cfg.syss_mask) ==0x0 , +100 ,MAX_MODULE_SOFTRESET_WAIT ); +} +/* At this point the module is configured enough to read the revision */ static int sysc_init_module (struct sysc *ddata) {
@@ -960,6 +998,14 @@ static int sysc_init_module(struct sysc *ddata)return 0 ; } + error =sysc_reset (ddata); +if (error) { +dev_err (ddata->dev,"Reset failed with %d\n" , error); +pm_runtime_put_sync (ddata->dev); + +return error; + } + ddata->revision =sysc_read_revision (ddata);pm_runtime_put_sync (ddata->dev);
Signature · 1 line
2.17.1
Re: [PATCH v5 4/6] bus: ti-sysc: Add support for software reset
Hi Tony,
Quoted 19 lines · Tony Lindgren
Hi,
Quoted 2 lines · Faiz Abbas
Add support for the software reset of a target interconnect module using its sysconfig and sysstatus registers.
...
Quoted 2 lines
drivers/bus/ti-sysc.c +0
-0...
drivers/bus/ti-sysc.c static void sysc_init_revision_quirks(struct sysc *ddata)
Quoted 4 lines
drivers/bus/ti-sysc.c +4
-0+static int sysc_reset (struct sysc *ddata) +{ +int offset = ddata->offsets[SYSC_SYSCONFIG ]; +int val =sysc_read (ddata, offset);Testing with omap4 sysc dts data I noticed we already have modules where there is only rev register and no
SYSC_SYSCONFIG. So not using legacy mode. The above offset with-ENODEVvalue will not work :)
Quoted 2 lines
I added some more checks and moved them to the reset function.
Great. Thanks for the fix.
Thanks,
Faiz
PATCH v5 5/6 ARM: dts: Add generic interconnect target module node for MCAN
In reply to Faiz AbbasThe ti-sysc driver provides support for manipulating the idle modes and interconnect level resets.
Add the generic interconnect target module node for MCAN to support the same.
--- arch/arm/boot/dts/dra76x.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/boot/dts/dra76x.dtsi +18 -0
@@ -11,6 +11,24 @@ / { compatible = "ti,dra762", "ti,dra7"; + ocp { + target-module@42c01900 { + compatible = "ti,sysc-dra7-mcan", "ti,sysc"; + ranges = <0x0 0x42c00000 0x2000>; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x42c01900 0x4>, + <0x42c01904 0x4>, + <0x42c01908 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP4_SOFTRESET | + SYSC_DRA7_MCAN_ENAWAKEUP)>; + ti,syss-mask = <1>; + clocks = <&wkupaon_clkctrl DRA7_ADC_CLKCTRL 0>; + clock-names = "fck"; + }; + }; + }; /* MCAN interrupts are hard-wired to irqs 67, 68 */
Signature · 1 line
2.17.0
PATCH v5 6/6 ARM: dts: dra76x: Add MCAN node
In reply to Faiz AbbasAdd support for the MCAN peripheral which supports both classic CAN messages along with the new CAN-FD message.
Add MCAN node to evm and enable it with a maximum datarate of 5 mbps
--- arch/arm/boot/dts/dra76-evm.dts | 6 ++++++ arch/arm/boot/dts/dra76x.dtsi | 13 +++++++++++++ 2 files changed, 19 insertions(+)
arch/arm/boot/dts/dra76-evm.dts +6 -0
@@ -436,3 +436,9 @@ phys = <&pcie1_phy>, <&pcie2_phy>; phy-names = "pcie-phy0", "pcie-phy1"; }; + +&m_can0 { + can-transceiver { + max-bitrate = <5000000>; + }; +};
arch/arm/boot/dts/dra76x.dtsi +13 -0
@@ -26,6 +26,19 @@ ti,syss-mask = <1>; clocks = <&wkupaon_clkctrl DRA7_ADC_CLKCTRL 0>; clock-names = "fck"; + + m_can0: mcan@1a00 { + compatible = "bosch,m_can"; + reg = <0x1a00 0x4000>, <0x0 0x18FC>; + reg-names = "m_can", "message_ram"; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "int0", "int1"; + clocks = <&mcan_clk>, <&l3_iclk_div>; + clock-names = "cclk", "hclk"; + bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; + }; }; };
Signature · 1 line
2.17.0