m68k: add basic set of devicetrees
Subsystems (3)
PATCH v4 1/12 m68k: add basic set of devicetrees
This patch adds a basic group of devicetrees, one for each cpu family, including actually just uart and dspi devices, since these are the drivers supporting devicetree (support added in this patch-set).
---
Changes for v2:
- add mcf54xx.dtsi and mcf537x.dtsi
Changes for v3:
- none
Changes for v4:
- none
--- arch/m68k/dts/mcf5208.dtsi | 36 ++++++++ arch/m68k/dts/mcf5227x.dtsi | 48 ++++++++++ arch/m68k/dts/mcf523x.dtsi | 44 ++++++++++ arch/m68k/dts/mcf5249.dtsi | 38 ++++++++ arch/m68k/dts/mcf5253.dtsi | 44 ++++++++++ arch/m68k/dts/mcf5271.dtsi | 44 ++++++++++ arch/m68k/dts/mcf5272.dtsi | 38 ++++++++ arch/m68k/dts/mcf5275.dtsi | 44 ++++++++++ arch/m68k/dts/mcf5282.dtsi | 44 ++++++++++ arch/m68k/dts/mcf5301x.dtsi | 48 ++++++++++ arch/m68k/dts/mcf5307.dtsi | 39 +++++++++ arch/m68k/dts/mcf5329.dtsi | 36 ++++++++ arch/m68k/dts/mcf537x.dtsi | 36 ++++++++ arch/m68k/dts/mcf5441x.dtsi | 87 +++++++++++++++++++ arch/m68k/dts/mcf5445x.dtsi | 48 ++++++++++ arch/m68k/dts/mcf54xx.dtsi | 40 +++++++++ doc/device-tree-bindings/serial/mcf-uart.txt | 19 ++++ doc/device-tree-bindings/spi/spi-mcf-dspi.txt | 30 +++++++ 18 files changed, 763 insertions(+) create mode 100644 arch/m68k/dts/mcf5208.dtsi create mode 100644 arch/m68k/dts/mcf5227x.dtsi create mode 100644 arch/m68k/dts/mcf523x.dtsi create mode 100644 arch/m68k/dts/mcf5249.dtsi create mode 100644 arch/m68k/dts/mcf5253.dtsi create mode 100644 arch/m68k/dts/mcf5271.dtsi create mode 100644 arch/m68k/dts/mcf5272.dtsi create mode 100644 arch/m68k/dts/mcf5275.dtsi create mode 100644 arch/m68k/dts/mcf5282.dtsi create mode 100644 arch/m68k/dts/mcf5301x.dtsi create mode 100644 arch/m68k/dts/mcf5307.dtsi create mode 100644 arch/m68k/dts/mcf5329.dtsi create mode 100644 arch/m68k/dts/mcf537x.dtsi create mode 100644 arch/m68k/dts/mcf5441x.dtsi create mode 100644 arch/m68k/dts/mcf5445x.dtsi create mode 100644 arch/m68k/dts/mcf54xx.dtsi create mode 100644 doc/device-tree-bindings/serial/mcf-uart.txt create mode 100644 doc/device-tree-bindings/spi/spi-mcf-dspi.txt
arch/m68k/dts/mcf5208.dtsi new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5208"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + uart0: uart at fc060000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc060000 0x40>; + status = "disabled"; + }; + + uart1: uart at fc064000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc064000 0x40>; + status = "disabled"; + }; + + uart2: uart at fc068000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc068000 0x40>; + status = "disabled"; + }; + }; +};
arch/m68k/dts/mcf5227x.dtsi new file +48 -0
48 lines not on this page · raw message
arch/m68k/dts/mcf523x.dtsi new file +44 -0
44 lines not on this page · raw message
arch/m68k/dts/mcf5249.dtsi new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5249"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + mbar: mbar at 10000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x10000000 0x10000>; + reg = <0x10000000 0x10000>; + + uart0: uart at 1c0 { + compatible = "fsl,mcf-uart"; + reg = <0x1c0 0x40>; + status = "disabled"; + }; + + uart1: uart at 200 { + compatible = "fsl,mcf-uart"; + reg = <0x200 0x40>; + status = "disabled"; + }; + }; + }; +};
arch/m68k/dts/mcf5253.dtsi new file +44 -0
44 lines not on this page · raw message
arch/m68k/dts/mcf5271.dtsi new file +44 -0
44 lines not on this page · raw message
arch/m68k/dts/mcf5272.dtsi new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5272"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + mbar: mbar at 10000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x10000000 0x10000>; + reg = <0x10000000 0x10000>; + + uart0: uart at 100 { + compatible = "fsl,mcf-uart"; + reg = <0x100 0x40>; + status = "disabled"; + }; + + uart1: uart at 140 { + compatible = "fsl,mcf-uart"; + reg = <0x140 0x40>; + status = "disabled"; + }; + }; + }; +};
arch/m68k/dts/mcf5275.dtsi new file +44 -0
44 lines not on this page · raw message
arch/m68k/dts/mcf5282.dtsi new file +44 -0
44 lines not on this page · raw message
arch/m68k/dts/mcf5301x.dtsi new file +48 -0
48 lines not on this page · raw message
arch/m68k/dts/mcf5307.dtsi new file +39 -0
@@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5307"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + /* MBAR */ + mbar: mbar at 10000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x10000000 0x10000>; + reg = <0x10000000 0x10000>; + + uart0: uart at 1c0 { + compatible = "fsl,mcf-uart"; + reg = <0x1c0 0x40>; + status = "disabled"; + }; + + uart1: uart at 200 { + compatible = "fsl,mcf-uart"; + reg = <0x200 0x40>; + status = "disabled"; + }; + }; + }; +};
arch/m68k/dts/mcf5329.dtsi new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5329"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + uart0: uart at fc060000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc060000 0x40>; + status = "disabled"; + }; + + uart1: uart at fc064000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc064000 0x40>; + status = "disabled"; + }; + + uart2: uart at fc068000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc068000 0x40>; + status = "disabled"; + }; + }; +};
arch/m68k/dts/mcf537x.dtsi new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf5329"; + + aliases { + serial0 = &uart0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + uart0: uart at fc060000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc060000 0x40>; + status = "disabled"; + }; + + uart1: uart at fc064000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc064000 0x40>; + status = "disabled"; + }; + + uart2: uart at fc068000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc068000 0x40>; + status = "disabled"; + }; + }; +};
arch/m68k/dts/mcf5441x.dtsi new file +87 -0
87 lines not on this page · raw message
arch/m68k/dts/mcf5445x.dtsi new file +48 -0
48 lines not on this page · raw message
arch/m68k/dts/mcf54xx.dtsi new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/ { + compatible = "fsl,mcf54x5"; + + aliases { + /* TO DO, clarify on serial, this SoC seems to have SPC and + * no UARTS. + */ + spi0 = &dspi0; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + mbar: mbar at 80000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x80000000 0x10000>; + reg = <0x80000000 0x10000>; + + dspi0: dspi at 8a00 { + compatible = "fsl,mcf-dspi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x8a00 0x100>; + spi-max-frequency = <50000000>; + num-cs = <4>; + spi-mode = <0>; + status = "disabled"; + }; + }; + }; +};
doc/device-tree-bindings/serial/mcf-uart.txt new file +19 -0
@@ -0,0 +1,19 @@ +Freescale ColdFire UART + +Required properties: +- compatible : should be "fsl,mcf-uart" +- reg: start address and size of the registers + +Example: + +soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + uart0: uart at fc060000 { + compatible = "fsl,mcf-uart"; + reg = <0xfc060000 0x40>; + status = "disabled"; + }; +};
doc/device-tree-bindings/spi/spi-mcf-dspi.txt new file +30 -0
@@ -0,0 +1,30 @@ +Freescale ColdFire DSPI controller + +Required properties: +- compatible : "fsl,mcf-dspi" +- #address-cells: <1>, as required by generic SPI binding +- #size-cells: <0>, also as required by generic SPI binding +- reg : offset and length of the register set for the device + +Optional properties: +- spi-max-frequency : max supported spi frequency +- num-cs : the number of the chipselect signals +- spi-mode: spi motorola mode, 0 to 3 +- ctar-params: CTAR0 to 7 register configuration, as an array + of 8 integer fields for each register, where each register + is defined as: <fmsz, pcssck, pasc, pdt, cssck, asc, dt, br>. + +Example: + +dspi0: dspi at fc05c000 { + compatible = "fsl,mcf-dspi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0xfc05c000 0x100>; + spi-max-frequency = <50000000>; + num-cs = <4>; + spi-mode = <0>; + ctar-fields = <7, 0, 0, 0, 0, 0, 1, 6>, + <7, 0, 0, 0, 0, 0, 1, 6>, + <7, 0, 0, 0, 0, 0, 1, 6>; +};
Signature · 1 line
2.19.1
PATCH v4 2/12 m68k: architecture changes to support fdt
This patch adds fdt support to the m68k architecture.
---
Changes for v2:
- add OF_CONTROL, DM and DM_SERIAL as default config options for all cpu families
Changes for v3:
- none
Changes for v4:
- bisectability, moved SUPPORT_OF_CONTROL to next patch
--- arch/m68k/Kconfig | 33 +++++++++++++++++++++++++++++++++ arch/m68k/cpu/u-boot.lds | 6 ++++-- 2 files changed, 37 insertions(+), 2 deletions(-)
arch/m68k/Kconfig +33 -0
@@ -6,36 +6,69 @@ config SYS_ARCH # processor family config MCF520x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF52x2 + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF523x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF530x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF5301x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF532x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF537x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF5441x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF5445x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF5227x + select OF_CONTROL + select DM + select DM_SERIAL bool config MCF547x_8x + select OF_CONTROL + select DM + select DM_SERIAL bool # processor type
arch/m68k/cpu/u-boot.lds +4 -2
@@ -68,13 +68,15 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .; - . = ALIGN(256); + . = ALIGN(4); __init_begin = .; .text.init : { *(.text.init) } .data.init : { *(.data.init) } - . = ALIGN(256); + . = ALIGN(4); __init_end = .; + _end = .; + __bss_start = .; .bss (NOLOAD) : {
Signature · 1 line
2.19.1
PATCH v4 3/12 m68k: add initial dts files for all m68k boards
In reply to Angelo DureghelloThis patch adds basic dts files for all the m68k boards.
---
Changes for v2:
- new patch
Changes for v3:
- none
Changes for v4:
- none
--- arch/m68k/dts/M5208EVBE.dts | 22 +++++++ arch/m68k/dts/M52277EVB.dts | 25 ++++++++ arch/m68k/dts/M52277EVB_stmicro.dts | 22 +++++++ arch/m68k/dts/M5235EVB.dts | 22 +++++++ arch/m68k/dts/M5235EVB_Flash32.dts | 22 +++++++ arch/m68k/dts/M5249EVB.dts | 22 +++++++ arch/m68k/dts/M5253DEMO.dts | 22 +++++++ arch/m68k/dts/M5272C3.dts | 22 +++++++ arch/m68k/dts/M5275EVB.dts | 22 +++++++ arch/m68k/dts/M5282EVB.dts | 22 +++++++ arch/m68k/dts/M53017EVB.dts | 22 +++++++ arch/m68k/dts/M5329AFEE.dts | 22 +++++++ arch/m68k/dts/M5329BFEE.dts | 22 +++++++ arch/m68k/dts/M5373EVB.dts | 22 +++++++ arch/m68k/dts/M54418TWR.dts | 25 ++++++++ arch/m68k/dts/M54418TWR_nand_mii.dts | 25 ++++++++ arch/m68k/dts/M54418TWR_nand_rmii.dts | 25 ++++++++ arch/m68k/dts/M54418TWR_nand_rmii_lowfreq.dts | 25 ++++++++ arch/m68k/dts/M54418TWR_serial_mii.dts | 25 ++++++++ arch/m68k/dts/M54418TWR_serial_rmii.dts | 25 ++++++++ arch/m68k/dts/M54451EVB.dts | 25 ++++++++ arch/m68k/dts/M54451EVB_stmicro.dts | 25 ++++++++ arch/m68k/dts/M54455EVB.dts | 25 ++++++++ arch/m68k/dts/M54455EVB_a66.dts | 25 ++++++++ arch/m68k/dts/M54455EVB_i66.dts | 25 ++++++++ arch/m68k/dts/M54455EVB_intel.dts | 26 +++++++++ arch/m68k/dts/M54455EVB_stm33.dts | 25 ++++++++ arch/m68k/dts/M5475AFE.dts | 13 +++++ arch/m68k/dts/M5475BFE.dts | 13 +++++ arch/m68k/dts/M5475CFE.dts | 13 +++++ arch/m68k/dts/M5475DFE.dts | 13 +++++ arch/m68k/dts/M5475EFE.dts | 13 +++++ arch/m68k/dts/M5475FFE.dts | 13 +++++ arch/m68k/dts/M5475GFE.dts | 13 +++++ arch/m68k/dts/M5485AFE.dts | 17 ++++++ arch/m68k/dts/M5485BFE.dts | 17 ++++++ arch/m68k/dts/M5485CFE.dts | 17 ++++++ arch/m68k/dts/M5485DFE.dts | 17 ++++++ arch/m68k/dts/M5485EFE.dts | 17 ++++++ arch/m68k/dts/M5485FFE.dts | 17 ++++++ arch/m68k/dts/M5485GFE.dts | 17 ++++++ arch/m68k/dts/M5485HFE.dts | 17 ++++++ arch/m68k/dts/Makefile | 58 +++++++++++++++++++ arch/m68k/dts/amcore.dts | 22 +++++++ arch/m68k/dts/astro_mcf5373l.dts | 22 +++++++ arch/m68k/dts/cobra5272.dts | 22 +++++++ arch/m68k/dts/eb_cpu5282.dts | 22 +++++++ arch/m68k/dts/eb_cpu5282_internal.dts | 22 +++++++ arch/m68k/dts/stmark2.dts | 34 +++++++++++ 49 files changed, 1066 insertions(+) create mode 100644 arch/m68k/dts/M5208EVBE.dts create mode 100644 arch/m68k/dts/M52277EVB.dts create mode 100644 arch/m68k/dts/M52277EVB_stmicro.dts create mode 100644 arch/m68k/dts/M5235EVB.dts create mode 100644 arch/m68k/dts/M5235EVB_Flash32.dts create mode 100644 arch/m68k/dts/M5249EVB.dts create mode 100644 arch/m68k/dts/M5253DEMO.dts create mode 100644 arch/m68k/dts/M5272C3.dts create mode 100644 arch/m68k/dts/M5275EVB.dts create mode 100644 arch/m68k/dts/M5282EVB.dts create mode 100644 arch/m68k/dts/M53017EVB.dts create mode 100644 arch/m68k/dts/M5329AFEE.dts create mode 100644 arch/m68k/dts/M5329BFEE.dts create mode 100644 arch/m68k/dts/M5373EVB.dts create mode 100644 arch/m68k/dts/M54418TWR.dts create mode 100644 arch/m68k/dts/M54418TWR_nand_mii.dts create mode 100644 arch/m68k/dts/M54418TWR_nand_rmii.dts create mode 100644 arch/m68k/dts/M54418TWR_nand_rmii_lowfreq.dts create mode 100644 arch/m68k/dts/M54418TWR_serial_mii.dts create mode 100644 arch/m68k/dts/M54418TWR_serial_rmii.dts create mode 100644 arch/m68k/dts/M54451EVB.dts create mode 100644 arch/m68k/dts/M54451EVB_stmicro.dts create mode 100644 arch/m68k/dts/M54455EVB.dts create mode 100644 arch/m68k/dts/M54455EVB_a66.dts create mode 100644 arch/m68k/dts/M54455EVB_i66.dts create mode 100644 arch/m68k/dts/M54455EVB_intel.dts create mode 100644 arch/m68k/dts/M54455EVB_stm33.dts create mode 100644 arch/m68k/dts/M5475AFE.dts create mode 100644 arch/m68k/dts/M5475BFE.dts create mode 100644 arch/m68k/dts/M5475CFE.dts create mode 100644 arch/m68k/dts/M5475DFE.dts create mode 100644 arch/m68k/dts/M5475EFE.dts create mode 100644 arch/m68k/dts/M5475FFE.dts create mode 100644 arch/m68k/dts/M5475GFE.dts create mode 100644 arch/m68k/dts/M5485AFE.dts create mode 100644 arch/m68k/dts/M5485BFE.dts create mode 100644 arch/m68k/dts/M5485CFE.dts create mode 100644 arch/m68k/dts/M5485DFE.dts create mode 100644 arch/m68k/dts/M5485EFE.dts create mode 100644 arch/m68k/dts/M5485FFE.dts create mode 100644 arch/m68k/dts/M5485GFE.dts create mode 100644 arch/m68k/dts/M5485HFE.dts create mode 100644 arch/m68k/dts/Makefile create mode 100644 arch/m68k/dts/amcore.dts create mode 100644 arch/m68k/dts/astro_mcf5373l.dts create mode 100644 arch/m68k/dts/cobra5272.dts create mode 100644 arch/m68k/dts/eb_cpu5282.dts create mode 100644 arch/m68k/dts/eb_cpu5282_internal.dts create mode 100644 arch/m68k/dts/stmark2.dts
arch/m68k/dts/M5208EVBE.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5208.dtsi" + +/ { + model = "Freescale M5208EVBE"; + compatible = "fsl,M5208EVBE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M52277EVB.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5227x.dtsi" + +/ { + model = "Freescale M52277EVB"; + compatible = "fsl,M52277EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M52277EVB_stmicro.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5227x.dtsi" + +/ { + model = "Freescale M52277_stmicro"; + compatible = "fsl,M52277_stmicro"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5235EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf523x.dtsi" + +/ { + model = "Freescale M5235EVB"; + compatible = "fsl,M5235EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5235EVB_Flash32.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf523x.dtsi" + +/ { + model = "Freescale M5235EVB_Flash32"; + compatible = "fsl,M5235EVB_Flash32"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5249EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5249.dtsi" + +/ { + model = "Freescale M5249EVB"; + compatible = "fsl,M5249EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5253DEMO.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5253.dtsi" + +/ { + model = "Freescale M5253DEMO"; + compatible = "fsl,M5253DEMO"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5272C3.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5272.dtsi" + +/ { + model = "Freescale M5272C3"; + compatible = "fsl,M5272C3"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5275EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5275.dtsi" + +/ { + model = "Freescale M5275EVB"; + compatible = "fsl,M5275EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5282EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5282.dtsi" + +/ { + model = "Freescale M5282EVB"; + compatible = "fsl,M5282EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M53017EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5301x.dtsi" + +/ { + model = "Freescale M53017EVB"; + compatible = "fsl,M53017EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5329AFEE.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5329.dtsi" + +/ { + model = "Freescale M5329AFEE"; + compatible = "fsl,M5329AFEE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5329BFEE.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5329.dtsi" + +/ { + model = "Freescale M5329BFEE"; + compatible = "fsl,M5329BFEE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M5373EVB.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf537x.dtsi" + +/ { + model = "Freescale M5373EVB"; + compatible = "fsl,M5373EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/M54418TWR.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR"; + compatible = "fsl,M54418TWR"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54418TWR_nand_mii.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR_nand_mii"; + compatible = "fsl,M54418TWR_nand_mii"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54418TWR_nand_rmii.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR_nand_rmii"; + compatible = "fsl,M54418TWR_nand_rmii"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54418TWR_nand_rmii_lowfreq.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR_nand_rmii_lowfreq"; + compatible = "fsl,M54418TWR_nand_rmii_lowfreq"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54418TWR_serial_mii.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR_serial_mii"; + compatible = "fsl,M54418TWR_serial_mii"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54418TWR_serial_rmii.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Freescale M54418TWR_serial_rmii"; + compatible = "fsl,M54418TWR_serial_rmii"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54451EVB.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54451EVB"; + compatible = "fsl,M54451EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54451EVB_stmicro.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54451EVB_stmicro"; + compatible = "fsl,M54451EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54455EVB.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54455EVB"; + compatible = "fsl,M54455EVB"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54455EVB_a66.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54455EVB_a66"; + compatible = "fsl,M54455EVB_a66"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54455EVB_i66.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54455EVB_i66"; + compatible = "fsl,M54455EVB_i66"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M54455EVB_intel.dts new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54455EVB_intel"; + compatible = "fsl,M5275EVB_intel"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +}; +
arch/m68k/dts/M54455EVB_stm33.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5445x.dtsi" + +/ { + model = "Freescale M54455EVB_stm33"; + compatible = "fsl,M5275EVB_stm33"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + status = "okay"; +};
arch/m68k/dts/M5475AFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475AFE"; + compatible = "fsl,M5475AFE"; +}; +
arch/m68k/dts/M5475BFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475BFE"; + compatible = "fsl,M5475BFE"; +}; +
arch/m68k/dts/M5475CFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475CFE"; + compatible = "fsl,M5475CFE"; +}; +
arch/m68k/dts/M5475DFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475DFE"; + compatible = "fsl,M5475DFE"; +}; +
arch/m68k/dts/M5475EFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475EFE"; + compatible = "fsl,M5475EFE"; +}; +
arch/m68k/dts/M5475FFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475FFE"; + compatible = "fsl,M5475FFE"; +}; +
arch/m68k/dts/M5475GFE.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5475GFE"; + compatible = "fsl,M5475GFE"; +}; +
arch/m68k/dts/M5485AFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485AFE"; + compatible = "fsl,M5485AFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485BFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485BFE"; + compatible = "fsl,M5485BFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485CFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485CFE"; + compatible = "fsl,M5485CFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485DFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485DFE"; + compatible = "fsl,M5485DFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485EFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485EFE"; + compatible = "fsl,M5485EFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485FFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485FFE"; + compatible = "fsl,M5485FFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485GFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485GFE"; + compatible = "fsl,M5485GFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/M5485HFE.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf54xx.dtsi" + +/ { + model = "Freescale M5485HFE"; + compatible = "fsl,M5485HFE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; +
arch/m68k/dts/Makefile new file +58 -0
58 lines not on this page · raw message
arch/m68k/dts/amcore.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5307.dtsi" + +/ { + model = "Sysam AMCORE"; + compatible = "sysam,AMCORE"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/astro_mcf5373l.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf537x.dtsi" + +/ { + model = "Astro mcf5373l"; + compatible = "astro,mcf5373l"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/cobra5272.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5272.dtsi" + +/ { + model = "Cobra 5272"; + compatible = "cobra,M5272"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/eb_cpu5282.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5282.dtsi" + +/ { + model = "BuS eb_cpuM5282"; + compatible = "bus,eb_cpuM5282"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/eb_cpu5282_internal.dts new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5282.dtsi" + +/ { + model = "BuS eb_cpu5282_internals"; + compatible = "bus,eb_cpu5282_internals"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; +
arch/m68k/dts/stmark2.dts new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Angelo Dureghello <[email protected]> + */ + +/dts-v1/; +/include/ "mcf5441x.dtsi" + +/ { + model = "Sysam stmark2"; + compatible = "sysam,stmark2"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; + status = "okay"; +}; + +&dspi0 { + spi-mode = <3>; + status = "okay"; + + flash: is25lp128 at 1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-flash"; + spi-max-frequency = <60000000>; + reg = <1>; + }; +};
Signature · 1 line
2.19.1
PATCH v4 4/12 m68k: enabling long jumps on mcf54x5 SoCs
In reply to Angelo DureghelloGrowing of binary size asks for long assembly jumps.
---
Changes for v2:
- new patch
Changes for v3:
- none
Changes for v4:
- none
--- arch/m68k/cpu/mcf547x_8x/start.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/m68k/cpu/mcf547x_8x/start.S +4 -2
@@ -131,7 +131,8 @@ _start: * then (and always) gd struct space will be reserved */ move.l %sp, -(%sp) - bsr board_init_f_alloc_reserve + move.l #board_init_f_alloc_reserve, %a1 + jsr (%a1) /* update stack and frame-pointers */ move.l %d0, %sp
@@ -139,7 +140,8 @@ _start: /* initialize reserved area */ move.l %d0, -(%sp) - bsr board_init_f_init_reserve + move.l #board_init_f_init_reserve, %a1 + jsr (%a1) /* run low-level CPU init code (from flash) */ jbsr cpu_init_f
Signature · 1 line
2.19.1
PATCH v4 5/12 configs: enable use of DT for all m68k boards
In reply to Angelo DureghelloEnable DT usage for all m68k boards. To provide a working single binary, the dts has been kept as embedded.
---
Changes for v2:
- new patch
Changes for v3:
- none
Changes for v4:
- remove CONFIG_OF_EMBED=y
--- configs/M5208EVBE_defconfig | 1 + configs/M52277EVB_defconfig | 1 + configs/M52277EVB_stmicro_defconfig | 1 + configs/M5235EVB_Flash32_defconfig | 1 + configs/M5235EVB_defconfig | 1 + configs/M5249EVB_defconfig | 1 + configs/M5253DEMO_defconfig | 1 + configs/M5272C3_defconfig | 1 + configs/M5275EVB_defconfig | 1 + configs/M5282EVB_defconfig | 1 + configs/M53017EVB_defconfig | 1 + configs/M5329AFEE_defconfig | 1 + configs/M5329BFEE_defconfig | 1 + configs/M5373EVB_defconfig | 1 + configs/M54418TWR_defconfig | 1 + configs/M54418TWR_nand_mii_defconfig | 1 + configs/M54418TWR_nand_rmii_defconfig | 1 + configs/M54418TWR_nand_rmii_lowfreq_defconfig | 1 + configs/M54418TWR_serial_mii_defconfig | 1 + configs/M54418TWR_serial_rmii_defconfig | 1 + configs/M54451EVB_defconfig | 1 + configs/M54451EVB_stmicro_defconfig | 1 + configs/M54455EVB_a66_defconfig | 1 + configs/M54455EVB_defconfig | 1 + configs/M54455EVB_i66_defconfig | 1 + configs/M54455EVB_intel_defconfig | 1 + configs/M54455EVB_stm33_defconfig | 1 + configs/M5475AFE_defconfig | 1 + configs/M5475BFE_defconfig | 1 + configs/M5475CFE_defconfig | 1 + configs/M5475DFE_defconfig | 1 + configs/M5475EFE_defconfig | 1 + configs/M5475FFE_defconfig | 1 + configs/M5475GFE_defconfig | 1 + configs/M5485AFE_defconfig | 1 + configs/M5485BFE_defconfig | 1 + configs/M5485CFE_defconfig | 1 + configs/M5485DFE_defconfig | 1 + configs/M5485EFE_defconfig | 1 + configs/M5485FFE_defconfig | 1 + configs/M5485GFE_defconfig | 1 + configs/M5485HFE_defconfig | 1 + configs/amcore_defconfig | 1 + configs/astro_mcf5373l_defconfig | 1 + configs/cobra5272_defconfig | 1 + configs/eb_cpu5282_defconfig | 1 + configs/eb_cpu5282_internal_defconfig | 1 + configs/stmark2_defconfig | 1 + 48 files changed, 48 insertions(+)
configs/M5208EVBE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M5208EVBE=y +CONFIG_DEFAULT_DEVICE_TREE="M5208EVBE" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M52277EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M52277EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M52277EVB" CONFIG_SYS_EXTRA_OPTIONS="SYS_SPANSION_BOOT" CONFIG_BOOTDELAY=3 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M52277EVB_stmicro_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x43E00000 CONFIG_TARGET_M52277EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M52277EVB_stmicro" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_STMICRO_BOOT" CONFIG_BOOTDELAY=3 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M5235EVB_Flash32_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFC00000 CONFIG_TARGET_M5235EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5235EVB_Flash32" CONFIG_SYS_EXTRA_OPTIONS="NORFLASH_PS32BIT" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M5235EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_M5235EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5235EVB" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M5249EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_M5249EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5249EVB" CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M5253DEMO_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5253DEMO=y +CONFIG_DEFAULT_DEVICE_TREE="M5253DEMO" CONFIG_BOOTDELAY=5 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M5272C3_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_M5272C3=y +CONFIG_DEFAULT_DEVICE_TREE="M5272C3" CONFIG_BOOTDELAY=5 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M5275EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_M5275EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5275EVB" CONFIG_BOOTDELAY=5 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M5282EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_M5282EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5282EVB" CONFIG_BOOTDELAY=5 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/M53017EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M53017EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M53017EVB" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/mtdblock3 rw rootfstype=jffs2"
configs/M5329AFEE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M5329EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5329AFEE" CONFIG_SYS_EXTRA_OPTIONS="NANDFLASH_SIZE=0" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M5329BFEE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M5329EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5329BFEE" CONFIG_SYS_EXTRA_OPTIONS="NANDFLASH_SIZE=16" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M5373EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M5373EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5373EVB" CONFIG_SYS_EXTRA_OPTIONS="NANDFLASH_SIZE=16" CONFIG_BOOTDELAY=1 # CONFIG_DISPLAY_BOARDINFO is not set
configs/M54418TWR_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_SERIAL_BOOT,SYS_INPUT_CLKSRC=50000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=192.168.1.1:/tftpboot/192.168.1.2 ip=192.168.1.2:192.168.1.1:192.168.1.1: 255.255.255.0::eth0:off:rw console=ttyS0,115200"
configs/M54418TWR_nand_mii_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR_nand_mii" CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BOOT,SYS_INPUT_CLKSRC=25000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/mtdblock2 rw rootfstype=jffs2 mtdparts=NAND:1M(u-boot)ro,7M(kernel)ro,-(jffs2) console=ttyS0,115200"
configs/M54418TWR_nand_rmii_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR_nand_rmii" CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BOOT,SYS_INPUT_CLKSRC=50000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/mtdblock2 rw rootfstype=jffs2 mtdparts=NAND:1M(u-boot)ro,7M(kernel)ro,-(jffs2) console=ttyS0,115200"
configs/M54418TWR_nand_rmii_lowfreq_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR_nand_rmii_lowfreq" CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BOOT,LOW_MCFCLK,SYS_INPUT_CLKSRC=50000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/mtdblock2 rw rootfstype=jffs2 mtdparts=NAND:1M(u-boot)ro,7M(kernel)ro,-(jffs2) console=ttyS0,115200"
configs/M54418TWR_serial_mii_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR_serial_mii" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_SERIAL_BOOT,SYS_INPUT_CLKSRC=25000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=192.168.1.1:/tftpboot/192.168.1.2 ip=192.168.1.2:192.168.1.1:192.168.1.1: 255.255.255.0::eth0:off:rw console=ttyS0,115200"
configs/M54418TWR_serial_rmii_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54418TWR=y +CONFIG_DEFAULT_DEVICE_TREE="M54418TWR_serial_rmii" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_SERIAL_BOOT,SYS_INPUT_CLKSRC=50000000" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=192.168.1.1:/tftpboot/192.168.1.2 ip=192.168.1.2:192.168.1.1:192.168.1.1: 255.255.255.0::eth0:off:rw console=ttyS0,115200"
configs/M54451EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M54451EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54451EVB" CONFIG_SYS_EXTRA_OPTIONS="SYS_INPUT_CLKSRC=24000000" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54451EVB_stmicro_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_M54451EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54451EVB_stmicro" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_STMICRO_BOOT,SYS_INPUT_CLKSRC=24000000" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54455EVB_a66_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x4000000 CONFIG_TARGET_M54455EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54455EVB_a66" CONFIG_SYS_EXTRA_OPTIONS="SYS_ATMEL_BOOT,SYS_INPUT_CLKSRC=66666666" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54455EVB_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x4000000 CONFIG_TARGET_M54455EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54455EVB" CONFIG_SYS_EXTRA_OPTIONS="SYS_ATMEL_BOOT,SYS_INPUT_CLKSRC=33333333" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54455EVB_i66_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M54455EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54455EVB_i66" CONFIG_SYS_EXTRA_OPTIONS="SYS_INTEL_BOOT,SYS_INPUT_CLKSRC=66666666" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54455EVB_intel_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x0 CONFIG_TARGET_M54455EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54455EVB_intel" CONFIG_SYS_EXTRA_OPTIONS="SYS_INTEL_BOOT,SYS_INPUT_CLKSRC=33333333" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M54455EVB_stm33_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x4FE00000 CONFIG_TARGET_M54455EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M54455EVB_stm33" CONFIG_SYS_EXTRA_OPTIONS="SYS_STMICRO_BOOT,CF_SBF,SYS_INPUT_CLKSRC=33333333" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y
configs/M5475AFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475AFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475BFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475BFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=16" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475CFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475CFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=16,SYS_VIDEO,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475DFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475DFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475EFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475EFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_VIDEO,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475FFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475FFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=32,SYS_VIDEO,SYS_USBCTRL,SYS_DRAMSZ1=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5475GFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5475EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5475GFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=133333333,SYS_BOOTSZ=4,SYS_DRAMSZ=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485AFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485AFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485BFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485BFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=16" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485CFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485CFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=16,SYS_VIDEO,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485DFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485DFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485EFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485EFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_VIDEO,SYS_USBCTRL" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485FFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485FFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=32,SYS_VIDEO,SYS_USBCTRL,SYS_DRAMSZ1=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485GFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485GFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=4,SYS_DRAMSZ=64" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/M5485HFE_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF800000 CONFIG_TARGET_M5485EVB=y +CONFIG_DEFAULT_DEVICE_TREE="M5485HFE" CONFIG_SYS_EXTRA_OPTIONS="SYS_BUSCLK=100000000,SYS_BOOTSZ=2,SYS_DRAMSZ=64,SYS_NOR1SZ=16,SYS_VIDEO" CONFIG_BOOTDELAY=1 # CONFIG_CMDLINE_EDITING is not set
configs/amcore_defconfig +1 -0
@@ -2,6 +2,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFC00000 CONFIG_SYS_MALLOC_F_LEN=0x800 CONFIG_TARGET_AMCORE=y +CONFIG_DEFAULT_DEVICE_TREE="amcore" CONFIG_BOOTDELAY=1 CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set
configs/astro_mcf5373l_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_TARGET_ASTRO_MCF5373L=y +CONFIG_DEFAULT_DEVICE_TREE="astro_mcf5373l" CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS=" console=ttyS2,115200 rootfstype=romfs loaderversion=$loaderversion"
configs/cobra5272_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFFE00000 CONFIG_TARGET_COBRA5272=y +CONFIG_DEFAULT_DEVICE_TREE="cobra5272" CONFIG_BOOTDELAY=5 # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_CMDLINE_EDITING is not set
configs/eb_cpu5282_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xFF000000 CONFIG_TARGET_EB_CPU5282=y +CONFIG_DEFAULT_DEVICE_TREE="eb_cpu5282" CONFIG_SYS_EXTRA_OPTIONS="SYS_MONITOR_BASE=0xFF000400" CONFIG_BOOTDELAY=5 # CONFIG_CONSOLE_MUX is not set
configs/eb_cpu5282_internal_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0xF0000000 CONFIG_TARGET_EB_CPU5282=y +CONFIG_DEFAULT_DEVICE_TREE="eb_cpu5282_internal" CONFIG_SYS_EXTRA_OPTIONS="SYS_MONITOR_BASE=0xF0000418" CONFIG_BOOTDELAY=5 # CONFIG_CONSOLE_MUX is not set
configs/stmark2_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_M68K=y CONFIG_SYS_TEXT_BASE=0x47E00000 CONFIG_TARGET_STMARK2=y +CONFIG_DEFAULT_DEVICE_TREE="stmark2" CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_SERIAL_BOOT,SYS_INPUT_CLKSRC=30000000" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_HUSH_PARSER=y
Signature · 1 line
2.19.1
PATCH v4 6/12 drivers: spi: cf_spi: add Kconfig option
In reply to Angelo DureghelloThis patch adds cf_spi DM Kconfig option.
---
Changes for v2:
- new patch
Changes for v3:
- re-put SOFT_SPI in place, options are out of alphabetical order Changes for v4:
- none
--- drivers/spi/Kconfig | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/Kconfig +6 -0
@@ -87,6 +87,12 @@ config CADENCE_QSPI used to access the SPI NOR flash on platforms embedding this Cadence IP core. +config CF_SPI + bool "ColdFire SPI driver" + help + Enable the ColdFire SPI driver. This driver can be used on + some m68k SoCs. + config DESIGNWARE_SPI bool "Designware SPI driver" help
Signature · 1 line
2.19.1
PATCH v4 7/12 drivers: spi: cf_spi: convert to driver model
In reply to Angelo DureghelloConverting to driver model and removes non-dm code.
---
Changes for v2:
- removed non DM code part
- add default setup of CTAR registers
- add DT CTAR register setup support
Changes for v3:
- changed commit head
- removed spi_slave reference
- add #ifdefs for the case OF_PLATDATA is used
Changes for v4:
- remove all internal static functions that are no more needed including their code in the standard driver methods
- add helper macro for ctrl setup
- fix wrong fifo level check on spi tx
- move code inside same #if (avoid multiple #if on same option)
- removed externals and moved bus control code here
--- drivers/spi/cf_spi.c | 539 ++++++++++++++++-------- include/dm/platform_data/spi_coldfire.h | 29 ++ 2 files changed, 401 insertions(+), 167 deletions(-) create mode 100644 include/dm/platform_data/spi_coldfire.h
drivers/spi/cf_spi.c +372 -167
@@ -6,23 +6,31 @@* * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. * TsiChung Liew (Tsi-Chung.Liew at freescale.com) +* +* Support for DM and DT, non-DM code removed. +* Copyright (C) 2018 Angelo Dureghello <[email protected]> +* +* TODO: fsl_dspi.c should work as a driver for the DSPI module. */ #include <common.h> +#include <dm.h> +#include <dm/platform_data/spi_coldfire.h> #include <spi.h> #include <malloc.h> +#include <wait_bit.h> +#include <asm/coldfire/dspi.h> #include <asm/immap.h> +#include <asm/io.h> -struct cf_spi_slave { -struct spi_slave slave; +struct coldfire_spi_priv { +struct dspi *regs; +struct gpio *gpio_regs;uint baudrate; +int mode;int charbit; }; -extern void cfspi_port_conf (void ); -extern int cfspi_claim_bus (uint bus,uint cs); -extern void cfspi_release_bus (uint bus,uint cs); -DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_SPI_IDLE_VAL
@@ -33,149 +41,267 @@ DECLARE_GLOBAL_DATA_PTR;#endif #endif -#if defined(CONFIG_CF_DSPI )/* DSPI specific mode */ #define SPI_MODE_MOD 0x00200000#define SPI_DBLRATE 0x00100000 -static inline struct cf_spi_slave *to_cf_spi_slave (struct spi_slave *slave) +#define MCF_DSPI_MAX_CTAR_REGS 8 + +/* Default values */ +#define MCF_DSPI_DEFAULT_SCK_FREQ 10000000 +#define MCF_DSPI_DEFAULT_MAX_CS 4 +#define MCF_DSPI_DEFAULT_MODE 0 + +#define MCF_DSPI_DEFAULT_CTAR (DSPI_CTAR_TRSZ(7) | \ + DSPI_CTAR_PCSSCK_1CLK | \ + DSPI_CTAR_PASC(0) | \ + DSPI_CTAR_PDT(0) | \ + DSPI_CTAR_CSSCK(0) | \ + DSPI_CTAR_ASC(0) | \ + DSPI_CTAR_DT(1) | \ + DSPI_CTAR_BR(6)) + +#define setup_ctrl (ctrl, cs) ((ctrl & 0xFF000000) | ((1 << cs) << 16)) + +static inline void cfspi_tx (struct coldfire_spi_priv *cfspi, +u32 ctrl,u16 data) { - return container_of(slave, struct cf_spi_slave, slave); +/* +* Need to check fifo level here +*/ +while ((readl (&cfspi->regs->sr) &0x0000F000 ) >=0x4000 ) + ; + +writel (ctrl | data, &cfspi->regs->tfr); } -static void cfspi_init (void ) +static inline u16 cfspi_rx (struct coldfire_spi_priv *cfspi) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -cfspi_port_conf ();/* port configuration */ +while ((readl (&cfspi->regs->sr) &0x000000F0 ) ==0 ) + ; - dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | -DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | -DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | -DSPI_MCR_CRXF |DSPI_MCR_CTXF ; +return readw (&cfspi->regs->rfr); +} -/* Default setting in platform configuration */ -#ifdef CONFIG_SYS_DSPI_CTAR0 - dspi->ctar[0 ] =CONFIG_SYS_DSPI_CTAR0 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR1 - dspi->ctar[1 ] =CONFIG_SYS_DSPI_CTAR1 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR2 - dspi->ctar[2 ] =CONFIG_SYS_DSPI_CTAR2 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR3 - dspi->ctar[3 ] =CONFIG_SYS_DSPI_CTAR3 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR4 - dspi->ctar[4 ] =CONFIG_SYS_DSPI_CTAR4 ; +static int coldfire_spi_claim_bus (struct udevice *dev) +{ +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs;#endif -#ifdef CONFIG_SYS_DSPI_CTAR5 - dspi->ctar[5 ] =CONFIG_SYS_DSPI_CTAR5 ; + +if ((in_be32 (&dspi->sr) &DSPI_SR_TXRXS ) !=DSPI_SR_TXRXS ) +return -1 ; + +/* Clear FIFO and resume transfer */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +setbits_8 (&gpio->par_dma,GPIO_PAR_DMA_DACK0_PCS3 ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR6 - dspi->ctar[6 ] =CONFIG_SYS_DSPI_CTAR6 ; + +#ifdef CONFIG_MCF5441x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK ); +setbits_8 (&gpio->par_dspi0,GPIO_PAR_DSPI0_PCS0_DSPI0PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +setbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR7 - dspi->ctar[7 ] =CONFIG_SYS_DSPI_CTAR7 ; + +#ifdef CONFIG_MCF5227x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_UNMASK ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +setbits_8 (&gpio->par_timer,GPIO_PAR_TIMER_T2IN_DSPIPCS2 ); +break ; + }#endif +return 0 ; } -static void cfspi_tx (u32 ctrl,u16 data) +static int coldfire_spi_release_bus (struct udevice *dev) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -while ((dspi->sr &0x0000F000 ) >=4 ) ; - - dspi->tfr = (ctrl | data); -} +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs; +#endif -static u16 cfspi_rx (void ) -{ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; +/* Clear FIFO */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + } +#endif -while ((dspi->sr &0x000000F0 ) ==0 ) ; +#ifdef CONFIG_MCF5441x +if (slave_plat->cs ==1 ) +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +#endif -return (dspi->rfr &0xFFFF ); +#ifdef CONFIG_MCF5227x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +break ; + } +#endif +return 0 ; } -static int cfspi_xfer (struct spi_slave *slave,uint bitlen,const void *dout, -void *din,ulong flags) +static int coldfire_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din, +unsigned long flags) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct udevice *bus =dev_get_parent (dev); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dm_spi_slave_platdata *slave_plat =dev_get_parent_platdata (dev);u16 *spi_rd16 =NULL , *spi_wr16 =NULL ;u8 *spi_rd =NULL , *spi_wr =NULL ; -static u32 ctrl =0 ; +static u32 ctrl;uint len = bitlen >>3 ; -if (cfslave->charbit ==16 ) { +if (cfspi->charbit ==16 ) { bitlen >>=1 ; - spi_wr16 = (u16 *) dout; - spi_rd16 = (u16 *) din; + spi_wr16 = (u16 *)dout; + spi_rd16 = (u16 *)din; }else { - spi_wr = (u8 *) dout; - spi_rd = (u8 *) din; + spi_wr = (u8 *)dout; + spi_rd = (u8 *)din; }if ((flags &SPI_XFER_BEGIN ) ==SPI_XFER_BEGIN ) ctrl |=DSPI_TFR_CONT ; - ctrl = (ctrl &0xFF000000 ) | ((1 << slave->cs) <<16 ); + ctrl =setup_ctrl (ctrl, slave_plat->cs);if (len >1 ) {int tmp_len = len -1 ; +while (tmp_len--) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16++); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16++);else -cfspi_tx (ctrl, *spi_wr++); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr++); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16++ =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16++ =cfspi_rx (cfspi);else - *spi_rd++ =cfspi_rx (); + *spi_rd++ =cfspi_rx (cfspi); } } len =1 ;/* remaining byte */ } -if ((flags &SPI_XFER_END ) ==SPI_XFER_END ) +if (flags &SPI_XFER_END ) ctrl &= ~DSPI_TFR_CONT ;if (len) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16);else -cfspi_tx (ctrl, *spi_wr); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16 =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16 =cfspi_rx (cfspi);else - *spi_rd =cfspi_rx (); + *spi_rd =cfspi_rx (cfspi); } }else {/* dummy read */ -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -cfspi_rx (); +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +cfspi_rx (cfspi); }return 0 ; } -static struct spi_slave *cfspi_setup_slave (struct cf_spi_slave *cfslave, -uint mode) +static int coldfire_spi_set_speed (struct udevice *bus,uint max_hz) { +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int prescaler[] = {2 ,3 ,5 ,7 }; +int scaler[] = { +2 ,4 ,6 ,8 , +16 ,32 ,64 ,128 , +256 ,512 ,1024 ,2048 , +4096 ,8192 ,16384 ,32768 + }; +int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; +int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed; +u32 bus_setup; + + cfspi->baudrate = max_hz; +/* * bit definition for mode: * bit 31 - 28: Transfer size 3 to 16 bits
@@ -189,66 +315,37 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,* 11 - 8: Delay after transfer scaler * 7 - 0: SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST */ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -int prescaler[] = {2 ,3 ,5 ,7 }; -int scaler[] = { -2 ,4 ,6 ,8 , -16 ,32 ,64 ,128 , -256 ,512 ,1024 ,2048 , -4096 ,8192 ,16384 ,32768 - }; -int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; -int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed; -u32 bus_setup =0 ; + +/* Read current setup */ + bus_setup =readl (&dspi->ctar[bus->seq]); tmp = (prescaler[3 ] * scaler[15 ]);/* Maximum and minimum baudrate it can handle */ -if ((cfslave->baudrate > (gd->bus_clk >>1 )) || - (cfslave->baudrate < (gd->bus_clk / tmp))) { +if ((cfspi->baudrate > (gd->bus_clk >>1 )) || + (cfspi->baudrate < (gd->bus_clk / tmp))) {printf ("Exceed baudrate limitation: Max %d - Min %d\n" , (int )(gd->bus_clk >>1 ), (int )(gd->bus_clk / tmp)); -return NULL ; +return -1 ; }/* Activate Double Baud when it exceed 1/4 the bus clk */ -if ((CONFIG_SYS_DSPI_CTAR0 &DSPI_CTAR_DBR ) || - (cfslave->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { +if ((bus_setup &DSPI_CTAR_DBR ) || + (cfspi->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } -if (mode &SPI_CPOL ) - bus_setup |=DSPI_CTAR_CPOL ; -if (mode &SPI_CPHA ) - bus_setup |=DSPI_CTAR_CPHA ; -if (mode &SPI_LSB_FIRST ) - bus_setup |=DSPI_CTAR_LSBFE ; -/* Overwrite default value set in platform configuration file */ -if (mode &SPI_MODE_MOD ) { - -if ((mode &0xF0000000 ) ==0 ) - bus_setup |= - dspi->ctar[cfslave->slave.bus] &0x78000000 ; -else - bus_setup |= ((mode &0xF0000000 ) >>1 ); - +if (cfspi->mode &SPI_MODE_MOD ) {/* * Check to see if it is enabled by default in platform * config, or manual setting passed by mode parameter */ -if (mode &SPI_DBLRATE ) { +if (cfspi->mode &SPI_DBLRATE ) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } - bus_setup |= (mode &0x0FC00000 ) >>4 ;/* PSCSCK, PASC, PDT */ - bus_setup |= (mode &0x000FFF00 ) >>4 ;/* CSSCK, ASC, DT */ - }else - bus_setup |= (dspi->ctar[cfslave->slave.bus] &0x78FCFFF0 ); - - cfslave->charbit = - ((dspi->ctar[cfslave->slave.bus] &0x78000000 ) == -0x78000000 ) ?16 :8 ; + } pbrcnt =sizeof (prescaler) /sizeof (int ); brcnt =sizeof (scaler) /sizeof (int );
@@ -259,10 +356,10 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,for (j =0 ; j < brcnt; j++) { tmp = (baud_speed / scaler[j]) * (1 + dbr); -if (tmp > cfslave->baudrate) - diff = tmp - cfslave->baudrate; +if (tmp > cfspi->baudrate) + diff = tmp - cfspi->baudrate;else - diff = cfslave->baudrate - tmp; + diff = cfspi->baudrate - tmp;if (diff < bestmatch) { bestmatch = diff;
@@ -271,65 +368,173 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, } } } + + bus_setup &= ~(DSPI_CTAR_PBR (0x03 ) |DSPI_CTAR_BR (0x0f )); bus_setup |= (DSPI_CTAR_PBR (best_i) |DSPI_CTAR_BR (best_j)); - dspi->ctar[cfslave->slave.bus] = bus_setup; +writel (bus_setup, &dspi->ctar[bus->seq]); -return &cfslave->slave; +return 0 ; } -#endif /* CONFIG_CF_DSPI */ -#ifdef CONFIG_CMD_SPI -int spi_cs_is_valid (unsigned int bus,unsigned int cs) +static int coldfire_spi_set_mode (struct udevice *bus,uint mode) { -if (((cs >=0 ) && (cs <8 )) && ((bus >=0 ) && (bus <8 ))) -return 1 ; -else -return 0 ; -} +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +u32 bus_setup =0 ; -void spi_init (void ) -{ -cfspi_init (); -} + cfspi->mode = mode; -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct cf_spi_slave *cfslave; +if (cfspi->mode &SPI_CPOL ) + bus_setup |=DSPI_CTAR_CPOL ; +if (cfspi->mode &SPI_CPHA ) + bus_setup |=DSPI_CTAR_CPHA ; +if (cfspi->mode &SPI_LSB_FIRST ) + bus_setup |=DSPI_CTAR_LSBFE ; + +/* Overwrite default value set in platform configuration file */ +if (cfspi->mode &SPI_MODE_MOD ) { +if ((cfspi->mode &0xF0000000 ) ==0 ) + bus_setup |= +readl (&dspi->ctar[bus->seq]) &0x78000000 ; +else + bus_setup |= ((cfspi->mode &0xF0000000 ) >>1 ); -if (!spi_cs_is_valid (bus, cs)) -return NULL ; +/* PSCSCK, PASC, PDT */ + bus_setup |= (cfspi->mode &0x0FC00000 ) >>4 ; +/* CSSCK, ASC, DT */ + bus_setup |= (cfspi->mode &0x000FFF00 ) >>4 ; + }else { + bus_setup |= (readl (&dspi->ctar[bus->seq]) &0x78FCFFF0 ); + } - cfslave = spi_alloc_slave(struct cf_spi_slave, bus, cs); -if (!cfslave) -return NULL ; + cfspi->charbit = + ((readl (&dspi->ctar[bus->seq]) &0x78000000 ) == +0x78000000 ) ?16 :8 ; - cfslave->baudrate = max_hz; +setbits_be32 (&dspi->ctar[bus->seq], bus_setup); -/* specific setup */ -return cfspi_setup_slave (cfslave, mode); +return 0 ; } -void spi_free_slave (struct spi_slave *slave) +static int coldfire_spi_probe (struct udevice *bus) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct coldfire_spi_platdata *plat =dev_get_platdata (bus); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int i; -free (cfslave); -} + cfspi->regs = (struct dspi *)plat->regs_addr; + cfspi->gpio_regs = (struct gpio *)MMAP_GPIO ; -int spi_claim_bus (struct spi_slave *slave) -{ -return cfspi_claim_bus (slave->bus, slave->cs); + cfspi->baudrate = plat->speed_hz; + cfspi->mode = plat->mode; + +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) { +unsigned int ctar =0 ; + +if (plat->ctar[i][0 ] ==0 ) +break ; + + ctar =DSPI_CTAR_TRSZ (plat->ctar[i][0 ]) | +DSPI_CTAR_PCSSCK (plat->ctar[i][1 ]) | +DSPI_CTAR_PASC (plat->ctar[i][2 ]) | +DSPI_CTAR_PDT (plat->ctar[i][3 ]) | +DSPI_CTAR_CSSCK (plat->ctar[i][4 ]) | +DSPI_CTAR_ASC (plat->ctar[i][5 ]) | +DSPI_CTAR_DT (plat->ctar[i][6 ]) | +DSPI_CTAR_BR (plat->ctar[i][7 ]); + +writel (ctar, &cfspi->regs->ctar[i]); + } + +/* Default CTARs */ +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) +writel (MCF_DSPI_DEFAULT_CTAR , &dspi->ctar[i]); + + dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | +DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | +DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | +DSPI_MCR_CRXF |DSPI_MCR_CTXF ; + +return 0 ; } -void spi_release_bus (struct spi_slave *slave) +void spi_init (void ) { -cfspi_release_bus (slave->bus, slave->cs); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) +static int coldfire_dspi_ofdata_to_platdata (struct udevice *bus) { -return cfspi_xfer (slave, bitlen, dout, din, flags); +fdt_addr_t addr; +struct coldfire_spi_platdata *plat = bus->platdata; +const void *blob = gd->fdt_blob; +int node =dev_of_offset (bus); +int *ctar, len; + + addr =devfdt_get_addr (bus); +if (addr ==FDT_ADDR_T_NONE ) +return -ENOMEM ; + + plat->regs_addr = addr; + + plat->num_cs =fdtdec_get_int (blob, node,"num-cs" , +MCF_DSPI_DEFAULT_MAX_CS ); + + plat->speed_hz =fdtdec_get_int (blob, node,"spi-max-frequency" , +MCF_DSPI_DEFAULT_SCK_FREQ ); + + plat->mode =fdtdec_get_int (blob, node,"spi-mode" , +MCF_DSPI_DEFAULT_MODE ); + +memset (plat->ctar,0 ,sizeof (plat->ctar)); + + ctar = (int *)fdt_getprop (blob, node,"ctar-params" , &len); + +if (ctar && len) { +int i, q, ctar_regs; + + ctar_regs = len /sizeof (unsigned int ) /MAX_CTAR_FIELDS ; + +if (ctar_regs >MAX_CTAR_REGS ) + ctar_regs =MAX_CTAR_REGS ; + +for (i =0 ; i < ctar_regs; i++) { +for (q =0 ; q <MAX_CTAR_FIELDS ; q++) + plat->ctar[i][q] = *ctar++; + } + } + +debug ("DSPI: regs=%pa, max-frequency=%d, num-cs=%d, mode=%d\n" , + (void *)plat->regs_addr, + plat->speed_hz, plat->num_cs, plat->mode); + +return 0 ; } -#endif /* CONFIG_CMD_SPI */ + +static const struct udevice_id coldfire_spi_ids[] = { + { .compatible ="fsl,mcf-dspi" }, + { } +}; +#endif + +static const struct dm_spi_ops coldfire_spi_ops = { + .claim_bus = coldfire_spi_claim_bus, + .release_bus = coldfire_spi_release_bus, + .xfer = coldfire_spi_xfer, + .set_speed = coldfire_spi_set_speed, + .set_mode = coldfire_spi_set_mode, +}; + +U_BOOT_DRIVER (coldfire_spi) = { + .name ="spi_coldfire" , + .id =UCLASS_SPI , + .probe = coldfire_spi_probe, + .ops = &coldfire_spi_ops, + .platdata_auto_alloc_size =sizeof (struct coldfire_spi_platdata ), + .priv_auto_alloc_size =sizeof (struct coldfire_spi_priv ), +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .of_match = coldfire_spi_ids, + .ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata, +#endif +};
include/dm/platform_data/spi_coldfire.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2018 Angelo Dureghello <[email protected]> +*/ + +#ifndef __spi_coldfire_h +#define __spi_coldfire_h + +#define MAX_CTAR_REGS 8 +#define MAX_CTAR_FIELDS 8 + +/* +* struct coldfire_spi_platdata - information about a coldfire spi module +* +* @regs_addr: base address for module registers +* @speed_hz: default SCK frequency +* @mode: default SPI mode +* @num_cs: number of DSPI chipselect signals +*/ +struct coldfire_spi_platdata { +fdt_addr_t regs_addr; +uint speed_hz; +uint mode; +uint num_cs; +uint ctar[MAX_CTAR_REGS ][MAX_CTAR_FIELDS ]; +}; + +#endif /* __spi_coldfire_h */ +
Signature · 1 line
2.19.1
PATCH v4 7/12 drivers: spi: cf_spi: convert to driver model
Quoted 115 lines · Angelo Dureghello
Converting to driver model and removes non-dm code.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Angelo Dureghello <[email protected]>---
Changes for v2:
- removed non DM code part
- add default setup of CTAR registers
- add DT CTAR register setup support
Changes for v3:
- changed commit head
- removedspi_slavereference
- add #ifdefs for the caseOF_PLATDATAis used
Changes for v4:
- remove all internal static functions that are no more needed including their code in the standard driver methods
- add helper macro for ctrl setup
- fix wrong fifo level check on spi tx
- move code inside same #if (avoid multiple #if on same option)
- removed externals and moved bus control code here--- drivers/spi/cf_spi.c | 539 ++++++++++++++++-------- include/dm/platform_data/spi_coldfire.h | 29 ++ 2 files changed, 401 insertions(+), 167 deletions(-) create mode 100644 include/dm/platform_data/spi_coldfire.hdrivers/spi/cf_spi.c +42
-12@@ -6,23 +6,31 @@* * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. * TsiChung Liew (Tsi-Chung.Liew at freescale.com) +* +* Support for DM and DT, non-DM code removed. +* Copyright (C) 2018 Angelo Dureghello <[email protected]> +* +* TODO: fsl_dspi.c should work as a driver for the DSPI module. */ #include <common.h> +#include <dm.h> +#include <dm/platform_data/spi_coldfire.h> #include <spi.h> #include <malloc.h> +#include <wait_bit.h> +#include <asm/coldfire/dspi.h> #include <asm/immap.h> +#include <asm/io.h> -struct cf_spi_slave { -struct spi_slave slave; +struct coldfire_spi_priv { +struct dspi *regs; +struct gpio *gpio_regs;uint baudrate; +int mode;int charbit; }; -extern void cfspi_port_conf (void ); -extern int cfspi_claim_bus (uint bus,uint cs); -extern void cfspi_release_bus (uint bus,uint cs); -DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_SPI_IDLE_VAL @@ -33,149 +41,267 @@ DECLARE_GLOBAL_DATA_PTR;#endif #endif -#if defined(CONFIG_CF_DSPI )/* DSPI specific mode */ #define SPI_MODE_MOD 0x00200000#define SPI_DBLRATE 0x00100000 -static inline struct cf_spi_slave *to_cf_spi_slave (struct spi_slave *slave) +#define MCF_DSPI_MAX_CTAR_REGS 8 + +/* Default values */ +#define MCF_DSPI_DEFAULT_SCK_FREQ 10000000 +#define MCF_DSPI_DEFAULT_MAX_CS 4 +#define MCF_DSPI_DEFAULT_MODE 0 + +#define MCF_DSPI_DEFAULT_CTAR (DSPI_CTAR_TRSZ(7) | \ + DSPI_CTAR_PCSSCK_1CLK | \ + DSPI_CTAR_PASC(0) | \ + DSPI_CTAR_PDT(0) | \ + DSPI_CTAR_CSSCK(0) | \ + DSPI_CTAR_ASC(0) | \ + DSPI_CTAR_DT(1) | \ + DSPI_CTAR_BR(6)) + +#define setup_ctrl (ctrl, cs) ((ctrl & 0xFF000000) | ((1 << cs) << 16)) + +static inline void cfspi_tx (struct coldfire_spi_priv *cfspi, +u32 ctrl,u16 data) { - return container_of(slave, struct cf_spi_slave, slave); +/* +* Need to check fifo level here +*/ +while ((readl (&cfspi->regs->sr) &0x0000F000 ) >=0x4000 ) + ; + +writel (ctrl | data, &cfspi->regs->tfr); } -static void cfspi_init (void ) +static inline u16 cfspi_rx (struct coldfire_spi_priv *cfspi) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 84
Quoted 10 lines
drivers/spi/cf_spi.c +4
-5-cfspi_port_conf ();/* port configuration */ +while ((readl (&cfspi->regs->sr) &0x000000F0 ) ==0 ) + ; - dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | -DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | -DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | -DSPI_MCR_CRXF |DSPI_MCR_CTXF ; +return readw (&cfspi->regs->rfr); +}
Look like you include wait header and forgot to implement wait_for_bit_* logic which I commented before.
Quoted 136 lines
drivers/spi/cf_spi.c +96
-31-/* Default setting in platform configuration */ -#ifdef CONFIG_SYS_DSPI_CTAR0 - dspi->ctar[0 ] =CONFIG_SYS_DSPI_CTAR0 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR1 - dspi->ctar[1 ] =CONFIG_SYS_DSPI_CTAR1 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR2 - dspi->ctar[2 ] =CONFIG_SYS_DSPI_CTAR2 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR3 - dspi->ctar[3 ] =CONFIG_SYS_DSPI_CTAR3 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR4 - dspi->ctar[4 ] =CONFIG_SYS_DSPI_CTAR4 ; +static int coldfire_spi_claim_bus (struct udevice *dev) +{ +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs;#endif -#ifdef CONFIG_SYS_DSPI_CTAR5 - dspi->ctar[5 ] =CONFIG_SYS_DSPI_CTAR5 ; + +if ((in_be32 (&dspi->sr) &DSPI_SR_TXRXS ) !=DSPI_SR_TXRXS ) +return -1 ; + +/* Clear FIFO and resume transfer */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +setbits_8 (&gpio->par_dma,GPIO_PAR_DMA_DACK0_PCS3 ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR6 - dspi->ctar[6 ] =CONFIG_SYS_DSPI_CTAR6 ; + +#ifdef CONFIG_MCF5441x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK ); +setbits_8 (&gpio->par_dspi0,GPIO_PAR_DSPI0_PCS0_DSPI0PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +setbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR7 - dspi->ctar[7 ] =CONFIG_SYS_DSPI_CTAR7 ; + +#ifdef CONFIG_MCF5227x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_UNMASK ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +setbits_8 (&gpio->par_timer,GPIO_PAR_TIMER_T2IN_DSPIPCS2 ); +break ; + }#endif +return 0 ; } -static void cfspi_tx (u32 ctrl,u16 data) +static int coldfire_spi_release_bus (struct udevice *dev) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -while ((dspi->sr &0x0000F000 ) >=4 ) ; - - dspi->tfr = (ctrl | data); -} +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs; +#endif -static u16 cfspi_rx (void ) -{ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; +/* Clear FIFO */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + }
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 197
Quoted 10 lines
drivers/spi/cf_spi.c +6
-2+#endif -while ((dspi->sr &0x000000F0 ) ==0 ) ; +#ifdef CONFIG_MCF5441x +if (slave_plat->cs ==1 ) +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +#endif -return (dspi->rfr &0xFFFF ); +#ifdef CONFIG_MCF5227x
Like this macro, along with above CONFIG_MCF5445x
Does it support separate compatible between these diff, if yes we can handle these via driver data.
Quoted 128 lines
drivers/spi/cf_spi.c +49
-35+switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +break ; + } +#endif +return 0 ; } -static int cfspi_xfer (struct spi_slave *slave,uint bitlen,const void *dout, -void *din,ulong flags) +static int coldfire_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din, +unsigned long flags) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct udevice *bus =dev_get_parent (dev); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dm_spi_slave_platdata *slave_plat =dev_get_parent_platdata (dev);u16 *spi_rd16 =NULL , *spi_wr16 =NULL ;u8 *spi_rd =NULL , *spi_wr =NULL ; -static u32 ctrl =0 ; +static u32 ctrl;uint len = bitlen >>3 ; -if (cfslave->charbit ==16 ) { +if (cfspi->charbit ==16 ) { bitlen >>=1 ; - spi_wr16 = (u16 *) dout; - spi_rd16 = (u16 *) din; + spi_wr16 = (u16 *)dout; + spi_rd16 = (u16 *)din; }else { - spi_wr = (u8 *) dout; - spi_rd = (u8 *) din; + spi_wr = (u8 *)dout; + spi_rd = (u8 *)din; }if ((flags &SPI_XFER_BEGIN ) ==SPI_XFER_BEGIN ) ctrl |=DSPI_TFR_CONT ; - ctrl = (ctrl &0xFF000000 ) | ((1 << slave->cs) <<16 ); + ctrl =setup_ctrl (ctrl, slave_plat->cs);if (len >1 ) {int tmp_len = len -1 ; +while (tmp_len--) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16++); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16++);else -cfspi_tx (ctrl, *spi_wr++); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr++); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16++ =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16++ =cfspi_rx (cfspi);else - *spi_rd++ =cfspi_rx (); + *spi_rd++ =cfspi_rx (cfspi); } } len =1 ;/* remaining byte */ } -if ((flags &SPI_XFER_END ) ==SPI_XFER_END ) +if (flags &SPI_XFER_END ) ctrl &= ~DSPI_TFR_CONT ;if (len) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16);else -cfspi_tx (ctrl, *spi_wr); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16 =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16 =cfspi_rx (cfspi);else - *spi_rd =cfspi_rx (); + *spi_rd =cfspi_rx (cfspi); } }else {/* dummy read */ -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -cfspi_rx (); +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +cfspi_rx (cfspi); }return 0 ; } -static struct spi_slave *cfspi_setup_slave (struct cf_spi_slave *cfslave, -uint mode) +static int coldfire_spi_set_speed (struct udevice *bus,uint max_hz) { +struct coldfire_spi_priv *cfspi =dev_get_priv (bus);
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 300
Quoted 10 lines
drivers/spi/cf_spi.c +10
-0+struct dspi *dspi = cfspi->regs; +int prescaler[] = {2 ,3 ,5 ,7 }; +int scaler[] = { +2 ,4 ,6 ,8 , +16 ,32 ,64 ,128 , +256 ,512 ,1024 ,2048 , +4096 ,8192 ,16384 ,32768 + }; +int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; +int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed;
bestmatch, replace with macro?
Quoted 158 lines
drivers/spi/cf_spi.c +45
-63+u32 bus_setup; + + cfspi->baudrate = max_hz; +/* * bit definition for mode: * bit 31 - 28: Transfer size 3 to 16 bits @@ -189,66 +315,37 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,* 11 - 8: Delay after transfer scaler * 7 - 0: SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST */ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -int prescaler[] = {2 ,3 ,5 ,7 }; -int scaler[] = { -2 ,4 ,6 ,8 , -16 ,32 ,64 ,128 , -256 ,512 ,1024 ,2048 , -4096 ,8192 ,16384 ,32768 - }; -int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; -int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed; -u32 bus_setup =0 ; + +/* Read current setup */ + bus_setup =readl (&dspi->ctar[bus->seq]); tmp = (prescaler[3 ] * scaler[15 ]);/* Maximum and minimum baudrate it can handle */ -if ((cfslave->baudrate > (gd->bus_clk >>1 )) || - (cfslave->baudrate < (gd->bus_clk / tmp))) { +if ((cfspi->baudrate > (gd->bus_clk >>1 )) || + (cfspi->baudrate < (gd->bus_clk / tmp))) {printf ("Exceed baudrate limitation: Max %d - Min %d\n" , (int )(gd->bus_clk >>1 ), (int )(gd->bus_clk / tmp)); -return NULL ; +return -1 ; }/* Activate Double Baud when it exceed 1/4 the bus clk */ -if ((CONFIG_SYS_DSPI_CTAR0 &DSPI_CTAR_DBR ) || - (cfslave->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { +if ((bus_setup &DSPI_CTAR_DBR ) || + (cfspi->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } -if (mode &SPI_CPOL ) - bus_setup |=DSPI_CTAR_CPOL ; -if (mode &SPI_CPHA ) - bus_setup |=DSPI_CTAR_CPHA ; -if (mode &SPI_LSB_FIRST ) - bus_setup |=DSPI_CTAR_LSBFE ; -/* Overwrite default value set in platform configuration file */ -if (mode &SPI_MODE_MOD ) { - -if ((mode &0xF0000000 ) ==0 ) - bus_setup |= - dspi->ctar[cfslave->slave.bus] &0x78000000 ; -else - bus_setup |= ((mode &0xF0000000 ) >>1 ); - +if (cfspi->mode &SPI_MODE_MOD ) {/* * Check to see if it is enabled by default in platform * config, or manual setting passed by mode parameter */ -if (mode &SPI_DBLRATE ) { +if (cfspi->mode &SPI_DBLRATE ) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } - bus_setup |= (mode &0x0FC00000 ) >>4 ;/* PSCSCK, PASC, PDT */ - bus_setup |= (mode &0x000FFF00 ) >>4 ;/* CSSCK, ASC, DT */ - }else - bus_setup |= (dspi->ctar[cfslave->slave.bus] &0x78FCFFF0 ); - - cfslave->charbit = - ((dspi->ctar[cfslave->slave.bus] &0x78000000 ) == -0x78000000 ) ?16 :8 ; + } pbrcnt =sizeof (prescaler) /sizeof (int ); brcnt =sizeof (scaler) /sizeof (int );@@ -259,10 +356,10 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,for (j =0 ; j < brcnt; j++) { tmp = (baud_speed / scaler[j]) * (1 + dbr); -if (tmp > cfslave->baudrate) - diff = tmp - cfslave->baudrate; +if (tmp > cfspi->baudrate) + diff = tmp - cfspi->baudrate;else - diff = cfslave->baudrate - tmp; + diff = cfspi->baudrate - tmp;if (diff < bestmatch) { bestmatch = diff;@@ -271,65 +368,173 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, } } } + + bus_setup &= ~(DSPI_CTAR_PBR (0x03 ) |DSPI_CTAR_BR (0x0f )); bus_setup |= (DSPI_CTAR_PBR (best_i) |DSPI_CTAR_BR (best_j)); - dspi->ctar[cfslave->slave.bus] = bus_setup; +writel (bus_setup, &dspi->ctar[bus->seq]); -return &cfslave->slave; +return 0 ; } -#endif /* CONFIG_CF_DSPI */ -#ifdef CONFIG_CMD_SPI -int spi_cs_is_valid (unsigned int bus,unsigned int cs) +static int coldfire_spi_set_mode (struct udevice *bus,uint mode) { -if (((cs >=0 ) && (cs <8 )) && ((bus >=0 ) && (bus <8 ))) -return 1 ; -else -return 0 ; -} +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +u32 bus_setup =0 ; -void spi_init (void ) -{ -cfspi_init (); -} + cfspi->mode = mode; -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct cf_spi_slave *cfslave; +if (cfspi->mode &SPI_CPOL ) + bus_setup |=DSPI_CTAR_CPOL ; +if (cfspi->mode &SPI_CPHA ) + bus_setup |=DSPI_CTAR_CPHA ; +if (cfspi->mode &SPI_LSB_FIRST ) + bus_setup |=DSPI_CTAR_LSBFE ; + +/* Overwrite default value set in platform configuration file */ +if (cfspi->mode &SPI_MODE_MOD ) { +if ((cfspi->mode &0xF0000000 ) ==0 ) + bus_setup |= +readl (&dspi->ctar[bus->seq]) &0x78000000 ; +else + bus_setup |= ((cfspi->mode &0xF0000000 ) >>1 ); -if (!spi_cs_is_valid (bus, cs)) -return NULL ; +/* PSCSCK, PASC, PDT */ + bus_setup |= (cfspi->mode &0x0FC00000 ) >>4 ; +/* CSSCK, ASC, DT */ + bus_setup |= (cfspi->mode &0x000FFF00 ) >>4 ;
drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 412
Quoted 10 lines
drivers/spi/cf_spi.c +6
-3+ }else { + bus_setup |= (readl (&dspi->ctar[bus->seq]) &0x78FCFFF0 ); + } - cfslave = spi_alloc_slave(struct cf_spi_slave, bus, cs); -if (!cfslave) -return NULL ; + cfspi->charbit = + ((readl (&dspi->ctar[bus->seq]) &0x78000000 ) == +0x78000000 ) ?16 :8 ;
Same here?
Quoted 134 lines
drivers/spi/cf_spi.c +104
-16- cfslave->baudrate = max_hz; +setbits_be32 (&dspi->ctar[bus->seq], bus_setup); -/* specific setup */ - return cfspi_setup_slave(cfslave, mode); +return 0 ; } -void spi_free_slave (struct spi_slave *slave) +static int coldfire_spi_probe (struct udevice *bus) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct coldfire_spi_platdata *plat =dev_get_platdata (bus); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int i; -free (cfslave); -} + cfspi->regs = (struct dspi *)plat->regs_addr; + cfspi->gpio_regs = (struct gpio *)MMAP_GPIO ; -int spi_claim_bus (struct spi_slave *slave) -{ -return cfspi_claim_bus (slave->bus, slave->cs); + cfspi->baudrate = plat->speed_hz; + cfspi->mode = plat->mode; + +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) { +unsigned int ctar =0 ; + +if (plat->ctar[i][0 ] ==0 ) +break ; + + ctar =DSPI_CTAR_TRSZ (plat->ctar[i][0 ]) | +DSPI_CTAR_PCSSCK (plat->ctar[i][1 ]) | +DSPI_CTAR_PASC (plat->ctar[i][2 ]) | +DSPI_CTAR_PDT (plat->ctar[i][3 ]) | +DSPI_CTAR_CSSCK (plat->ctar[i][4 ]) | +DSPI_CTAR_ASC (plat->ctar[i][5 ]) | +DSPI_CTAR_DT (plat->ctar[i][6 ]) | +DSPI_CTAR_BR (plat->ctar[i][7 ]); + +writel (ctar, &cfspi->regs->ctar[i]); + } + +/* Default CTARs */ +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) +writel (MCF_DSPI_DEFAULT_CTAR , &dspi->ctar[i]); + + dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | +DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | +DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | +DSPI_MCR_CRXF |DSPI_MCR_CTXF ; + +return 0 ; } -void spi_release_bus (struct spi_slave *slave) +void spi_init (void ) { -cfspi_release_bus (slave->bus, slave->cs); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) +static int coldfire_dspi_ofdata_to_platdata (struct udevice *bus) { -return cfspi_xfer (slave, bitlen, dout, din, flags); +fdt_addr_t addr; +struct coldfire_spi_platdata *plat = bus->platdata; +const void *blob = gd->fdt_blob; +int node =dev_of_offset (bus); +int *ctar, len; + + addr =devfdt_get_addr (bus); +if (addr ==FDT_ADDR_T_NONE ) +return -ENOMEM ; + + plat->regs_addr = addr; + + plat->num_cs =fdtdec_get_int (blob, node,"num-cs" , +MCF_DSPI_DEFAULT_MAX_CS ); + + plat->speed_hz =fdtdec_get_int (blob, node,"spi-max-frequency" , +MCF_DSPI_DEFAULT_SCK_FREQ ); + + plat->mode =fdtdec_get_int (blob, node,"spi-mode" , +MCF_DSPI_DEFAULT_MODE ); + +memset (plat->ctar,0 ,sizeof (plat->ctar)); + + ctar = (int *)fdt_getprop (blob, node,"ctar-params" , &len); + +if (ctar && len) { +int i, q, ctar_regs; + + ctar_regs = len /sizeof (unsigned int ) /MAX_CTAR_FIELDS ; + +if (ctar_regs >MAX_CTAR_REGS ) + ctar_regs =MAX_CTAR_REGS ; + +for (i =0 ; i < ctar_regs; i++) { +for (q =0 ; q <MAX_CTAR_FIELDS ; q++) + plat->ctar[i][q] = *ctar++; + } + } + +debug ("DSPI: regs=%pa, max-frequency=%d, num-cs=%d, mode=%d\n" , + (void *)plat->regs_addr, + plat->speed_hz, plat->num_cs, plat->mode); + +return 0 ; } -#endif /* CONFIG_CMD_SPI */ + +static const struct udevice_id coldfire_spi_ids[] = { + { .compatible ="fsl,mcf-dspi" }, + { } +}; +#endif + +static const struct dm_spi_ops coldfire_spi_ops = { + .claim_bus = coldfire_spi_claim_bus, + .release_bus = coldfire_spi_release_bus, + .xfer = coldfire_spi_xfer, + .set_speed = coldfire_spi_set_speed, + .set_mode = coldfire_spi_set_mode, +}; + +U_BOOT_DRIVER (coldfire_spi) = { + .name ="spi_coldfire" ,
drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 540
Quoted 10 lines
drivers/spi/cf_spi.c +10
-0+ .id = UCLASS_SPI, + .probe = coldfire_spi_probe, + .ops = &coldfire_spi_ops, + .platdata_auto_alloc_size = sizeof(struct coldfire_spi_platdata), + .priv_auto_alloc_size =sizeof (struct coldfire_spi_priv ), +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .of_match = coldfire_spi_ids, + .ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata, +#endif +};
This has to be as below
U_BOOT_DRIVER(coldfire_spi) = {
.name = "spi_coldfire",
.id = UCLASS_SPI,
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
.of_match = coldfire_spi_ids,
.ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct coldfire_spi_platdata),
#endif
.probe = coldfire_spi_probe,
.ops = &coldfire_spi_ops,
.priv_auto_alloc_size = sizeof(struct coldfire_spi_priv),
};
PATCH v4 7/12 drivers: spi: cf_spi: convert to driver model
Hi Jagan,
thanks for your comments,
Quoted 120 lines · Jagan Teki
Quoted 119 lines · Angelo Dureghello
Converting to driver model and removes non-dm code.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Angelo Dureghello <[email protected]>---
Changes for v2:
- removed non DM code part
- add default setup of CTAR registers
- add DT CTAR register setup support
Changes for v3:
- changed commit head
- removedspi_slavereference
- add #ifdefs for the caseOF_PLATDATAis used
Changes for v4:
- remove all internal static functions that are no more needed including their code in the standard driver methods
- add helper macro for ctrl setup
- fix wrong fifo level check on spi tx
- move code inside same #if (avoid multiple #if on same option)
- removed externals and moved bus control code here--- drivers/spi/cf_spi.c | 539 ++++++++++++++++-------- include/dm/platform_data/spi_coldfire.h | 29 ++ 2 files changed, 401 insertions(+), 167 deletions(-) create mode 100644 include/dm/platform_data/spi_coldfire.hdrivers/spi/cf_spi.c +44
-13@@ -6,23 +6,31 @@* * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. * TsiChung Liew (Tsi-Chung.Liew at freescale.com) +* +* Support for DM and DT, non-DM code removed. +* Copyright (C) 2018 Angelo Dureghello <[email protected]> +* +* TODO: fsl_dspi.c should work as a driver for the DSPI module. */ #include <common.h> +#include <dm.h> +#include <dm/platform_data/spi_coldfire.h> #include <spi.h> #include <malloc.h> +#include <wait_bit.h> +#include <asm/coldfire/dspi.h> #include <asm/immap.h> +#include <asm/io.h> -struct cf_spi_slave { -struct spi_slave slave; +struct coldfire_spi_priv { +struct dspi *regs; +struct gpio *gpio_regs;uint baudrate; +int mode;int charbit; }; -extern void cfspi_port_conf (void ); -extern int cfspi_claim_bus (uint bus,uint cs); -extern void cfspi_release_bus (uint bus,uint cs); -DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_SPI_IDLE_VAL @@ -33,149 +41,267 @@ DECLARE_GLOBAL_DATA_PTR;#endif #endif -#if defined(CONFIG_CF_DSPI )/* DSPI specific mode */ #define SPI_MODE_MOD 0x00200000#define SPI_DBLRATE 0x00100000 -static inline struct cf_spi_slave *to_cf_spi_slave (struct spi_slave *slave) +#define MCF_DSPI_MAX_CTAR_REGS 8 + +/* Default values */ +#define MCF_DSPI_DEFAULT_SCK_FREQ 10000000 +#define MCF_DSPI_DEFAULT_MAX_CS 4 +#define MCF_DSPI_DEFAULT_MODE 0 + +#define MCF_DSPI_DEFAULT_CTAR (DSPI_CTAR_TRSZ(7) | \ + DSPI_CTAR_PCSSCK_1CLK | \ + DSPI_CTAR_PASC(0) | \ + DSPI_CTAR_PDT(0) | \ + DSPI_CTAR_CSSCK(0) | \ + DSPI_CTAR_ASC(0) | \ + DSPI_CTAR_DT(1) | \ + DSPI_CTAR_BR(6)) + +#define setup_ctrl (ctrl, cs) ((ctrl & 0xFF000000) | ((1 << cs) << 16)) + +static inline void cfspi_tx (struct coldfire_spi_priv *cfspi, +u32 ctrl,u16 data) { - return container_of(slave, struct cf_spi_slave, slave); +/* +* Need to check fifo level here +*/ +while ((readl (&cfspi->regs->sr) &0x0000F000 ) >=0x4000 ) + ; + +writel (ctrl | data, &cfspi->regs->tfr); } -static void cfspi_init (void ) +static inline u16 cfspi_rx (struct coldfire_spi_priv *cfspi) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -cfspi_port_conf ();/* port configuration */ +while ((readl (&cfspi->regs->sr) &0x000000F0 ) ==0 ) + ;
Quoted 10 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 84
Quoted 6 lines
drivers/spi/cf_spi.c +2
-4- dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | -DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | -DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | -DSPI_MCR_CRXF |DSPI_MCR_CTXF ; +return readw (&cfspi->regs->rfr); +}Look like you include wait header and forgot to implement wait_for_bit_* logic which I commented before.
I tried to use it, this is why i forgot the header.
The fact is that wait_for_bit_* logic wait for one or more bit(s), but cannot wait for one "of" more bit(s), as in the above case. So seems cannot apply here.
Quoted 144 lines
Quoted 144 lines
drivers/spi/cf_spi.c +101
-32-/* Default setting in platform configuration */ -#ifdef CONFIG_SYS_DSPI_CTAR0 - dspi->ctar[0 ] =CONFIG_SYS_DSPI_CTAR0 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR1 - dspi->ctar[1 ] =CONFIG_SYS_DSPI_CTAR1 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR2 - dspi->ctar[2 ] =CONFIG_SYS_DSPI_CTAR2 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR3 - dspi->ctar[3 ] =CONFIG_SYS_DSPI_CTAR3 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR4 - dspi->ctar[4 ] =CONFIG_SYS_DSPI_CTAR4 ; +static int coldfire_spi_claim_bus (struct udevice *dev) +{ +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs;#endif -#ifdef CONFIG_SYS_DSPI_CTAR5 - dspi->ctar[5 ] =CONFIG_SYS_DSPI_CTAR5 ; + +if ((in_be32 (&dspi->sr) &DSPI_SR_TXRXS ) !=DSPI_SR_TXRXS ) +return -1 ; + +/* Clear FIFO and resume transfer */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +setbits_8 (&gpio->par_dma,GPIO_PAR_DMA_DACK0_PCS3 ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR6 - dspi->ctar[6 ] =CONFIG_SYS_DSPI_CTAR6 ; + +#ifdef CONFIG_MCF5441x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK ); +setbits_8 (&gpio->par_dspi0,GPIO_PAR_DSPI0_PCS0_DSPI0PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +setbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR7 - dspi->ctar[7 ] =CONFIG_SYS_DSPI_CTAR7 ; + +#ifdef CONFIG_MCF5227x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_UNMASK ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +setbits_8 (&gpio->par_timer,GPIO_PAR_TIMER_T2IN_DSPIPCS2 ); +break ; + }#endif +return 0 ; } -static void cfspi_tx (u32 ctrl,u16 data) +static int coldfire_spi_release_bus (struct udevice *dev) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -while ((dspi->sr &0x0000F000 ) >=4 ) ; - - dspi->tfr = (ctrl | data); -} +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs; +#endif -static u16 cfspi_rx (void ) -{ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; +/* Clear FIFO */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + } +#endif -while ((dspi->sr &0x000000F0 ) ==0 ) ; +#ifdef CONFIG_MCF5441x +if (slave_plat->cs ==1 ) +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +#endif
Quoted 8 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 197
Quoted 2 lines
drivers/spi/cf_spi.c +1
-1-return (dspi->rfr &0xFFFF ); +#ifdef CONFIG_MCF5227xLike this macro, along with above
CONFIG_MCF5445xDoes it support separate compatible between these diff, if yes we can handle these via driver data.
Ok, fixing this, nearly done, should be able to avoid all the config macroes probably.
Quoted 132 lines
Quoted 132 lines
drivers/spi/cf_spi.c +53
-35+switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +break ; + } +#endif +return 0 ; } -static int cfspi_xfer (struct spi_slave *slave,uint bitlen,const void *dout, -void *din,ulong flags) +static int coldfire_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din, +unsigned long flags) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct udevice *bus =dev_get_parent (dev); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dm_spi_slave_platdata *slave_plat =dev_get_parent_platdata (dev);u16 *spi_rd16 =NULL , *spi_wr16 =NULL ;u8 *spi_rd =NULL , *spi_wr =NULL ; -static u32 ctrl =0 ; +static u32 ctrl;uint len = bitlen >>3 ; -if (cfslave->charbit ==16 ) { +if (cfspi->charbit ==16 ) { bitlen >>=1 ; - spi_wr16 = (u16 *) dout; - spi_rd16 = (u16 *) din; + spi_wr16 = (u16 *)dout; + spi_rd16 = (u16 *)din; }else { - spi_wr = (u8 *) dout; - spi_rd = (u8 *) din; + spi_wr = (u8 *)dout; + spi_rd = (u8 *)din; }if ((flags &SPI_XFER_BEGIN ) ==SPI_XFER_BEGIN ) ctrl |=DSPI_TFR_CONT ; - ctrl = (ctrl &0xFF000000 ) | ((1 << slave->cs) <<16 ); + ctrl =setup_ctrl (ctrl, slave_plat->cs);if (len >1 ) {int tmp_len = len -1 ; +while (tmp_len--) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16++); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16++);else -cfspi_tx (ctrl, *spi_wr++); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr++); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16++ =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16++ =cfspi_rx (cfspi);else - *spi_rd++ =cfspi_rx (); + *spi_rd++ =cfspi_rx (cfspi); } } len =1 ;/* remaining byte */ } -if ((flags &SPI_XFER_END ) ==SPI_XFER_END ) +if (flags &SPI_XFER_END ) ctrl &= ~DSPI_TFR_CONT ;if (len) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16);else -cfspi_tx (ctrl, *spi_wr); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16 =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16 =cfspi_rx (cfspi);else - *spi_rd =cfspi_rx (); + *spi_rd =cfspi_rx (cfspi); } }else {/* dummy read */ -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -cfspi_rx (); +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +cfspi_rx (cfspi); }return 0 ; } -static struct spi_slave *cfspi_setup_slave (struct cf_spi_slave *cfslave, -uint mode) +static int coldfire_spi_set_speed (struct udevice *bus,uint max_hz) { +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int prescaler[] = {2 ,3 ,5 ,7 }; +int scaler[] = { +2 ,4 ,6 ,8 ,
Quoted 9 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 300
Quoted 6 lines
drivers/spi/cf_spi.c +6
-0+16 ,32 ,64 ,128 , +256 ,512 ,1024 ,2048 , +4096 ,8192 ,16384 ,32768 + }; +int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; +int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed;bestmatch, replace with macro?
Ok, done.
Quoted 162 lines
Quoted 162 lines
drivers/spi/cf_spi.c +48
-63+u32 bus_setup; + + cfspi->baudrate = max_hz; +/* * bit definition for mode: * bit 31 - 28: Transfer size 3 to 16 bits @@ -189,66 +315,37 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,* 11 - 8: Delay after transfer scaler * 7 - 0: SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST */ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -int prescaler[] = {2 ,3 ,5 ,7 }; -int scaler[] = { -2 ,4 ,6 ,8 , -16 ,32 ,64 ,128 , -256 ,512 ,1024 ,2048 , -4096 ,8192 ,16384 ,32768 - }; -int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; -int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed; -u32 bus_setup =0 ; + +/* Read current setup */ + bus_setup =readl (&dspi->ctar[bus->seq]); tmp = (prescaler[3 ] * scaler[15 ]);/* Maximum and minimum baudrate it can handle */ -if ((cfslave->baudrate > (gd->bus_clk >>1 )) || - (cfslave->baudrate < (gd->bus_clk / tmp))) { +if ((cfspi->baudrate > (gd->bus_clk >>1 )) || + (cfspi->baudrate < (gd->bus_clk / tmp))) {printf ("Exceed baudrate limitation: Max %d - Min %d\n" , (int )(gd->bus_clk >>1 ), (int )(gd->bus_clk / tmp)); -return NULL ; +return -1 ; }/* Activate Double Baud when it exceed 1/4 the bus clk */ -if ((CONFIG_SYS_DSPI_CTAR0 &DSPI_CTAR_DBR ) || - (cfslave->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { +if ((bus_setup &DSPI_CTAR_DBR ) || + (cfspi->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } -if (mode &SPI_CPOL ) - bus_setup |=DSPI_CTAR_CPOL ; -if (mode &SPI_CPHA ) - bus_setup |=DSPI_CTAR_CPHA ; -if (mode &SPI_LSB_FIRST ) - bus_setup |=DSPI_CTAR_LSBFE ; -/* Overwrite default value set in platform configuration file */ -if (mode &SPI_MODE_MOD ) { - -if ((mode &0xF0000000 ) ==0 ) - bus_setup |= - dspi->ctar[cfslave->slave.bus] &0x78000000 ; -else - bus_setup |= ((mode &0xF0000000 ) >>1 ); - +if (cfspi->mode &SPI_MODE_MOD ) {/* * Check to see if it is enabled by default in platform * config, or manual setting passed by mode parameter */ -if (mode &SPI_DBLRATE ) { +if (cfspi->mode &SPI_DBLRATE ) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } - bus_setup |= (mode &0x0FC00000 ) >>4 ;/* PSCSCK, PASC, PDT */ - bus_setup |= (mode &0x000FFF00 ) >>4 ;/* CSSCK, ASC, DT */ - }else - bus_setup |= (dspi->ctar[cfslave->slave.bus] &0x78FCFFF0 ); - - cfslave->charbit = - ((dspi->ctar[cfslave->slave.bus] &0x78000000 ) == -0x78000000 ) ?16 :8 ; + } pbrcnt =sizeof (prescaler) /sizeof (int ); brcnt =sizeof (scaler) /sizeof (int );@@ -259,10 +356,10 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,for (j =0 ; j < brcnt; j++) { tmp = (baud_speed / scaler[j]) * (1 + dbr); -if (tmp > cfslave->baudrate) - diff = tmp - cfslave->baudrate; +if (tmp > cfspi->baudrate) + diff = tmp - cfspi->baudrate;else - diff = cfslave->baudrate - tmp; + diff = cfspi->baudrate - tmp;if (diff < bestmatch) { bestmatch = diff;@@ -271,65 +368,173 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, } } } + + bus_setup &= ~(DSPI_CTAR_PBR (0x03 ) |DSPI_CTAR_BR (0x0f )); bus_setup |= (DSPI_CTAR_PBR (best_i) |DSPI_CTAR_BR (best_j)); - dspi->ctar[cfslave->slave.bus] = bus_setup; +writel (bus_setup, &dspi->ctar[bus->seq]); -return &cfslave->slave; +return 0 ; } -#endif /* CONFIG_CF_DSPI */ -#ifdef CONFIG_CMD_SPI -int spi_cs_is_valid (unsigned int bus,unsigned int cs) +static int coldfire_spi_set_mode (struct udevice *bus,uint mode) { -if (((cs >=0 ) && (cs <8 )) && ((bus >=0 ) && (bus <8 ))) -return 1 ; -else -return 0 ; -} +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +u32 bus_setup =0 ; -void spi_init (void ) -{ -cfspi_init (); -} + cfspi->mode = mode; -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct cf_spi_slave *cfslave; +if (cfspi->mode &SPI_CPOL ) + bus_setup |=DSPI_CTAR_CPOL ; +if (cfspi->mode &SPI_CPHA ) + bus_setup |=DSPI_CTAR_CPHA ; +if (cfspi->mode &SPI_LSB_FIRST ) + bus_setup |=DSPI_CTAR_LSBFE ; + +/* Overwrite default value set in platform configuration file */ +if (cfspi->mode &SPI_MODE_MOD ) { +if ((cfspi->mode &0xF0000000 ) ==0 ) + bus_setup |= +readl (&dspi->ctar[bus->seq]) &0x78000000 ; +else + bus_setup |= ((cfspi->mode &0xF0000000 ) >>1 ); -if (!spi_cs_is_valid (bus, cs)) -return NULL ; +/* PSCSCK, PASC, PDT */ + bus_setup |= (cfspi->mode &0x0FC00000 ) >>4 ; +/* CSSCK, ASC, DT */ + bus_setup |= (cfspi->mode &0x000FFF00 ) >>4 ; + }else { + bus_setup |= (readl (&dspi->ctar[bus->seq]) &0x78FCFFF0 ); + }
Quoted 9 lines
drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 412
Quoted 6 lines
drivers/spi/cf_spi.c +3
-3- cfslave = spi_alloc_slave(struct cf_spi_slave, bus, cs); -if (!cfslave) -return NULL ; + cfspi->charbit = + ((readl (&dspi->ctar[bus->seq]) &0x78000000 ) == +0x78000000 ) ?16 :8 ;Same here?
Ok, done.
Quoted 147 lines
Quoted 134 lines
drivers/spi/cf_spi.c +104
-16- cfslave->baudrate = max_hz; +setbits_be32 (&dspi->ctar[bus->seq], bus_setup); -/* specific setup */ - return cfspi_setup_slave(cfslave, mode); +return 0 ; } -void spi_free_slave (struct spi_slave *slave) +static int coldfire_spi_probe (struct udevice *bus) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct coldfire_spi_platdata *plat =dev_get_platdata (bus); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int i; -free (cfslave); -} + cfspi->regs = (struct dspi *)plat->regs_addr; + cfspi->gpio_regs = (struct gpio *)MMAP_GPIO ; -int spi_claim_bus (struct spi_slave *slave) -{ -return cfspi_claim_bus (slave->bus, slave->cs); + cfspi->baudrate = plat->speed_hz; + cfspi->mode = plat->mode; + +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) { +unsigned int ctar =0 ; + +if (plat->ctar[i][0 ] ==0 ) +break ; + + ctar =DSPI_CTAR_TRSZ (plat->ctar[i][0 ]) | +DSPI_CTAR_PCSSCK (plat->ctar[i][1 ]) | +DSPI_CTAR_PASC (plat->ctar[i][2 ]) | +DSPI_CTAR_PDT (plat->ctar[i][3 ]) | +DSPI_CTAR_CSSCK (plat->ctar[i][4 ]) | +DSPI_CTAR_ASC (plat->ctar[i][5 ]) | +DSPI_CTAR_DT (plat->ctar[i][6 ]) | +DSPI_CTAR_BR (plat->ctar[i][7 ]); + +writel (ctar, &cfspi->regs->ctar[i]); + } + +/* Default CTARs */ +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) +writel (MCF_DSPI_DEFAULT_CTAR , &dspi->ctar[i]); + + dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | +DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | +DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | +DSPI_MCR_CRXF |DSPI_MCR_CTXF ; + +return 0 ; } -void spi_release_bus (struct spi_slave *slave) +void spi_init (void ) { -cfspi_release_bus (slave->bus, slave->cs); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) +static int coldfire_dspi_ofdata_to_platdata (struct udevice *bus) { -return cfspi_xfer (slave, bitlen, dout, din, flags); +fdt_addr_t addr; +struct coldfire_spi_platdata *plat = bus->platdata; +const void *blob = gd->fdt_blob; +int node =dev_of_offset (bus); +int *ctar, len; + + addr =devfdt_get_addr (bus); +if (addr ==FDT_ADDR_T_NONE ) +return -ENOMEM ; + + plat->regs_addr = addr; + + plat->num_cs =fdtdec_get_int (blob, node,"num-cs" , +MCF_DSPI_DEFAULT_MAX_CS ); + + plat->speed_hz =fdtdec_get_int (blob, node,"spi-max-frequency" , +MCF_DSPI_DEFAULT_SCK_FREQ ); + + plat->mode =fdtdec_get_int (blob, node,"spi-mode" , +MCF_DSPI_DEFAULT_MODE ); + +memset (plat->ctar,0 ,sizeof (plat->ctar)); + + ctar = (int *)fdt_getprop (blob, node,"ctar-params" , &len); + +if (ctar && len) { +int i, q, ctar_regs; + + ctar_regs = len /sizeof (unsigned int ) /MAX_CTAR_FIELDS ; + +if (ctar_regs >MAX_CTAR_REGS ) + ctar_regs =MAX_CTAR_REGS ; + +for (i =0 ; i < ctar_regs; i++) { +for (q =0 ; q <MAX_CTAR_FIELDS ; q++) + plat->ctar[i][q] = *ctar++; + } + } + +debug ("DSPI: regs=%pa, max-frequency=%d, num-cs=%d, mode=%d\n" , + (void *)plat->regs_addr, + plat->speed_hz, plat->num_cs, plat->mode); + +return 0 ; } -#endif /* CONFIG_CMD_SPI */ + +static const struct udevice_id coldfire_spi_ids[] = { + { .compatible ="fsl,mcf-dspi" }, + { } +}; +#endif + +static const struct dm_spi_ops coldfire_spi_ops = { + .claim_bus = coldfire_spi_claim_bus, + .release_bus = coldfire_spi_release_bus, + .xfer = coldfire_spi_xfer, + .set_speed = coldfire_spi_set_speed, + .set_mode = coldfire_spi_set_mode, +}; + +U_BOOT_DRIVER (coldfire_spi) = { + .name ="spi_coldfire" ,drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 540
Quoted 10 lines
drivers/spi/cf_spi.c +10
-0+ .id = UCLASS_SPI, + .probe = coldfire_spi_probe, + .ops = &coldfire_spi_ops, + .platdata_auto_alloc_size = sizeof(struct coldfire_spi_platdata), + .priv_auto_alloc_size =sizeof (struct coldfire_spi_priv ), +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .of_match = coldfire_spi_ids, + .ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata, +#endif +};This has to be as below
Quoted 12 lines
U_BOOT_DRIVER(coldfire_spi)= {
.name = "spi_coldfire",
.id =UCLASS_SPI,
#ifCONFIG_IS_ENABLED(OF_CONTROL)&& !CONFIG_IS_ENABLED(OF_PLATDATA)
.of_match =coldfire_spi_ids,
.ofdata_to_platdata =coldfire_dspi_ofdata_to_platdata,
.platdata_auto_alloc_size =sizeof(struct coldfire_spi_platdata),
#endif
.probe =coldfire_spi_probe,
.ops =&coldfire_spi_ops,
.priv_auto_alloc_size =sizeof(struct coldfire_spi_priv),
};
Ok, done.
If there are no other points from you, will provide a new version in short.
Regards,
Angelo
PATCH v4 7/12 drivers: spi: cf_spi: convert to driver model
Quoted 775 lines · Angelo Dureghello
Hi Jagan,
thanks for your comments,
Quoted 120 lines · Jagan Teki
Quoted 119 lines · Angelo Dureghello
Converting to driver model and removes non-dm code.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Angelo Dureghello <[email protected]>---
Changes for v2:
- removed non DM code part
- add default setup of CTAR registers
- add DT CTAR register setup support
Changes for v3:
- changed commit head
- removedspi_slavereference
- add #ifdefs for the caseOF_PLATDATAis used
Changes for v4:
- remove all internal static functions that are no more needed including their code in the standard driver methods
- add helper macro for ctrl setup
- fix wrong fifo level check on spi tx
- move code inside same #if (avoid multiple #if on same option)
- removed externals and moved bus control code here--- drivers/spi/cf_spi.c | 539 ++++++++++++++++-------- include/dm/platform_data/spi_coldfire.h | 29 ++ 2 files changed, 401 insertions(+), 167 deletions(-) create mode 100644 include/dm/platform_data/spi_coldfire.hdrivers/spi/cf_spi.c +44
-13@@ -6,23 +6,31 @@* * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. * TsiChung Liew (Tsi-Chung.Liew at freescale.com) +* +* Support for DM and DT, non-DM code removed. +* Copyright (C) 2018 Angelo Dureghello <[email protected]> +* +* TODO: fsl_dspi.c should work as a driver for the DSPI module. */ #include <common.h> +#include <dm.h> +#include <dm/platform_data/spi_coldfire.h> #include <spi.h> #include <malloc.h> +#include <wait_bit.h> +#include <asm/coldfire/dspi.h> #include <asm/immap.h> +#include <asm/io.h> -struct cf_spi_slave { -struct spi_slave slave; +struct coldfire_spi_priv { +struct dspi *regs; +struct gpio *gpio_regs;uint baudrate; +int mode;int charbit; }; -extern void cfspi_port_conf (void ); -extern int cfspi_claim_bus (uint bus,uint cs); -extern void cfspi_release_bus (uint bus,uint cs); -DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_SPI_IDLE_VAL @@ -33,149 +41,267 @@ DECLARE_GLOBAL_DATA_PTR;#endif #endif -#if defined(CONFIG_CF_DSPI )/* DSPI specific mode */ #define SPI_MODE_MOD 0x00200000#define SPI_DBLRATE 0x00100000 -static inline struct cf_spi_slave *to_cf_spi_slave (struct spi_slave *slave) +#define MCF_DSPI_MAX_CTAR_REGS 8 + +/* Default values */ +#define MCF_DSPI_DEFAULT_SCK_FREQ 10000000 +#define MCF_DSPI_DEFAULT_MAX_CS 4 +#define MCF_DSPI_DEFAULT_MODE 0 + +#define MCF_DSPI_DEFAULT_CTAR (DSPI_CTAR_TRSZ(7) | \ + DSPI_CTAR_PCSSCK_1CLK | \ + DSPI_CTAR_PASC(0) | \ + DSPI_CTAR_PDT(0) | \ + DSPI_CTAR_CSSCK(0) | \ + DSPI_CTAR_ASC(0) | \ + DSPI_CTAR_DT(1) | \ + DSPI_CTAR_BR(6)) + +#define setup_ctrl (ctrl, cs) ((ctrl & 0xFF000000) | ((1 << cs) << 16)) + +static inline void cfspi_tx (struct coldfire_spi_priv *cfspi, +u32 ctrl,u16 data) { - return container_of(slave, struct cf_spi_slave, slave); +/* +* Need to check fifo level here +*/ +while ((readl (&cfspi->regs->sr) &0x0000F000 ) >=0x4000 ) + ; + +writel (ctrl | data, &cfspi->regs->tfr); } -static void cfspi_init (void ) +static inline u16 cfspi_rx (struct coldfire_spi_priv *cfspi) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -cfspi_port_conf ();/* port configuration */ +while ((readl (&cfspi->regs->sr) &0x000000F0 ) ==0 ) + ;Quoted 10 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 84
Quoted 6 lines
drivers/spi/cf_spi.c +2
-4- dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | -DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | -DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | -DSPI_MCR_CRXF |DSPI_MCR_CTXF ; +return readw (&cfspi->regs->rfr); +}Look like you include wait header and forgot to implement wait_for_bit_* logic which I commented before.
I tried to use it, this is why i forgot the header.
The fact is that wait_for_bit_* logic wait for one or more bit(s), but cannot wait for one "of" more bit(s), as in the above case. So seems cannot apply here.Quoted 144 lines
Quoted 144 lines
drivers/spi/cf_spi.c +101
-32-/* Default setting in platform configuration */ -#ifdef CONFIG_SYS_DSPI_CTAR0 - dspi->ctar[0 ] =CONFIG_SYS_DSPI_CTAR0 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR1 - dspi->ctar[1 ] =CONFIG_SYS_DSPI_CTAR1 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR2 - dspi->ctar[2 ] =CONFIG_SYS_DSPI_CTAR2 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR3 - dspi->ctar[3 ] =CONFIG_SYS_DSPI_CTAR3 ; -#endif -#ifdef CONFIG_SYS_DSPI_CTAR4 - dspi->ctar[4 ] =CONFIG_SYS_DSPI_CTAR4 ; +static int coldfire_spi_claim_bus (struct udevice *dev) +{ +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs;#endif -#ifdef CONFIG_SYS_DSPI_CTAR5 - dspi->ctar[5 ] =CONFIG_SYS_DSPI_CTAR5 ; + +if ((in_be32 (&dspi->sr) &DSPI_SR_TXRXS ) !=DSPI_SR_TXRXS ) +return -1 ; + +/* Clear FIFO and resume transfer */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +setbits_8 (&gpio->par_dma,GPIO_PAR_DMA_DACK0_PCS3 ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR6 - dspi->ctar[6 ] =CONFIG_SYS_DSPI_CTAR6 ; + +#ifdef CONFIG_MCF5441x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK ); +setbits_8 (&gpio->par_dspi0,GPIO_PAR_DSPI0_PCS0_DSPI0PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +setbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +break ; + }#endif -#ifdef CONFIG_SYS_DSPI_CTAR7 - dspi->ctar[7 ] =CONFIG_SYS_DSPI_CTAR7 ; + +#ifdef CONFIG_MCF5227x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_UNMASK ); +setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +setbits_8 (&gpio->par_timer,GPIO_PAR_TIMER_T2IN_DSPIPCS2 ); +break ; + }#endif +return 0 ; } -static void cfspi_tx (u32 ctrl,u16 data) +static int coldfire_spi_release_bus (struct udevice *dev) { -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; - -while ((dspi->sr &0x0000F000 ) >=4 ) ; - - dspi->tfr = (ctrl | data); -} +struct udevice *bus = dev->parent; +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +#if defined(CONFIG_MCF5445x) || \ + defined(CONFIG_MCF5441x) || defined(CONFIG_MCF5227x) +struct dm_spi_slave_platdata *slave_plat = +dev_get_parent_platdata (dev); +struct gpio *gpio = cfspi->gpio_regs; +#endif -static u16 cfspi_rx (void ) -{ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; +/* Clear FIFO */ +clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); + +#ifdef CONFIG_MCF5445x +switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 1 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS1_PCS1 ); +break ; +case 2 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS2_PCS2 ); +break ; +case 3 : +clrbits_8 (&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK ); +break ; +case 5 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS5_PCS5 ); +break ; + } +#endif -while ((dspi->sr &0x000000F0 ) ==0 ) ; +#ifdef CONFIG_MCF5441x +if (slave_plat->cs ==1 ) +clrbits_8 (&gpio->par_dspiow,GPIO_PAR_DSPIOW_DSPI0PSC1 ); +#endif Quoted 8 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 197
Quoted 2 lines
drivers/spi/cf_spi.c +1
-1-return (dspi->rfr &0xFFFF ); +#ifdef CONFIG_MCF5227xLike this macro, along with above
CONFIG_MCF5445xDoes it support separate compatible between these diff, if yes we can handle these via driver data.
Ok, fixing this, nearly done, should be able to avoid all the config macroes probably.
Quoted 132 lines
Quoted 132 lines
drivers/spi/cf_spi.c +53
-35+switch (slave_plat->cs) { +case 0 : +clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); +break ; +case 2 : +clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); +break ; + } +#endif +return 0 ; } -static int cfspi_xfer (struct spi_slave *slave,uint bitlen,const void *dout, -void *din,ulong flags) +static int coldfire_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din, +unsigned long flags) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct udevice *bus =dev_get_parent (dev); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dm_spi_slave_platdata *slave_plat =dev_get_parent_platdata (dev);u16 *spi_rd16 =NULL , *spi_wr16 =NULL ;u8 *spi_rd =NULL , *spi_wr =NULL ; -static u32 ctrl =0 ; +static u32 ctrl;uint len = bitlen >>3 ; -if (cfslave->charbit ==16 ) { +if (cfspi->charbit ==16 ) { bitlen >>=1 ; - spi_wr16 = (u16 *) dout; - spi_rd16 = (u16 *) din; + spi_wr16 = (u16 *)dout; + spi_rd16 = (u16 *)din; }else { - spi_wr = (u8 *) dout; - spi_rd = (u8 *) din; + spi_wr = (u8 *)dout; + spi_rd = (u8 *)din; }if ((flags &SPI_XFER_BEGIN ) ==SPI_XFER_BEGIN ) ctrl |=DSPI_TFR_CONT ; - ctrl = (ctrl &0xFF000000 ) | ((1 << slave->cs) <<16 ); + ctrl =setup_ctrl (ctrl, slave_plat->cs);if (len >1 ) {int tmp_len = len -1 ; +while (tmp_len--) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16++); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16++);else -cfspi_tx (ctrl, *spi_wr++); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr++); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16++ =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16++ =cfspi_rx (cfspi);else - *spi_rd++ =cfspi_rx (); + *spi_rd++ =cfspi_rx (cfspi); } } len =1 ;/* remaining byte */ } -if ((flags &SPI_XFER_END ) ==SPI_XFER_END ) +if (flags &SPI_XFER_END ) ctrl &= ~DSPI_TFR_CONT ;if (len) { -if (dout !=NULL ) { -if (cfslave->charbit ==16 ) -cfspi_tx (ctrl, *spi_wr16); +if (dout) { +if (cfspi->charbit ==16 ) +cfspi_tx (cfspi, ctrl, *spi_wr16);else -cfspi_tx (ctrl, *spi_wr); -cfspi_rx (); +cfspi_tx (cfspi, ctrl, *spi_wr); +cfspi_rx (cfspi); } -if (din !=NULL ) { -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -if (cfslave->charbit ==16 ) - *spi_rd16 =cfspi_rx (); +if (din) { +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +if (cfspi->charbit ==16 ) + *spi_rd16 =cfspi_rx (cfspi);else - *spi_rd =cfspi_rx (); + *spi_rd =cfspi_rx (cfspi); } }else {/* dummy read */ -cfspi_tx (ctrl,CONFIG_SPI_IDLE_VAL ); -cfspi_rx (); +cfspi_tx (cfspi, ctrl,CONFIG_SPI_IDLE_VAL ); +cfspi_rx (cfspi); }return 0 ; } -static struct spi_slave *cfspi_setup_slave (struct cf_spi_slave *cfslave, -uint mode) +static int coldfire_spi_set_speed (struct udevice *bus,uint max_hz) { +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int prescaler[] = {2 ,3 ,5 ,7 }; +int scaler[] = { +2 ,4 ,6 ,8 ,Quoted 9 lines
drivers/spi/cf_spi.c DECLARE_GLOBAL_DATA_PTR; · line 300
Quoted 6 lines
drivers/spi/cf_spi.c +6
-0+16 ,32 ,64 ,128 , +256 ,512 ,1024 ,2048 , +4096 ,8192 ,16384 ,32768 + }; +int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; +int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed;bestmatch, replace with macro?
Ok, done.
Quoted 162 lines
Quoted 162 lines
drivers/spi/cf_spi.c +48
-63+u32 bus_setup; + + cfspi->baudrate = max_hz; +/* * bit definition for mode: * bit 31 - 28: Transfer size 3 to 16 bits @@ -189,66 +315,37 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,* 11 - 8: Delay after transfer scaler * 7 - 0: SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST */ -volatile dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -int prescaler[] = {2 ,3 ,5 ,7 }; -int scaler[] = { -2 ,4 ,6 ,8 , -16 ,32 ,64 ,128 , -256 ,512 ,1024 ,2048 , -4096 ,8192 ,16384 ,32768 - }; -int i, j, pbrcnt, brcnt, diff, tmp, dbr =0 ; -int best_i, best_j, bestmatch =0x7FFFFFFF , baud_speed; -u32 bus_setup =0 ; + +/* Read current setup */ + bus_setup =readl (&dspi->ctar[bus->seq]); tmp = (prescaler[3 ] * scaler[15 ]);/* Maximum and minimum baudrate it can handle */ -if ((cfslave->baudrate > (gd->bus_clk >>1 )) || - (cfslave->baudrate < (gd->bus_clk / tmp))) { +if ((cfspi->baudrate > (gd->bus_clk >>1 )) || + (cfspi->baudrate < (gd->bus_clk / tmp))) {printf ("Exceed baudrate limitation: Max %d - Min %d\n" , (int )(gd->bus_clk >>1 ), (int )(gd->bus_clk / tmp)); -return NULL ; +return -1 ; }/* Activate Double Baud when it exceed 1/4 the bus clk */ -if ((CONFIG_SYS_DSPI_CTAR0 &DSPI_CTAR_DBR ) || - (cfslave->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { +if ((bus_setup &DSPI_CTAR_DBR ) || + (cfspi->baudrate > (gd->bus_clk / (prescaler[0 ] * scaler[0 ])))) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } -if (mode &SPI_CPOL ) - bus_setup |=DSPI_CTAR_CPOL ; -if (mode &SPI_CPHA ) - bus_setup |=DSPI_CTAR_CPHA ; -if (mode &SPI_LSB_FIRST ) - bus_setup |=DSPI_CTAR_LSBFE ; -/* Overwrite default value set in platform configuration file */ -if (mode &SPI_MODE_MOD ) { - -if ((mode &0xF0000000 ) ==0 ) - bus_setup |= - dspi->ctar[cfslave->slave.bus] &0x78000000 ; -else - bus_setup |= ((mode &0xF0000000 ) >>1 ); - +if (cfspi->mode &SPI_MODE_MOD ) {/* * Check to see if it is enabled by default in platform * config, or manual setting passed by mode parameter */ -if (mode &SPI_DBLRATE ) { +if (cfspi->mode &SPI_DBLRATE ) { bus_setup |=DSPI_CTAR_DBR ; dbr =1 ; } - bus_setup |= (mode &0x0FC00000 ) >>4 ;/* PSCSCK, PASC, PDT */ - bus_setup |= (mode &0x000FFF00 ) >>4 ;/* CSSCK, ASC, DT */ - }else - bus_setup |= (dspi->ctar[cfslave->slave.bus] &0x78FCFFF0 ); - - cfslave->charbit = - ((dspi->ctar[cfslave->slave.bus] &0x78000000 ) == -0x78000000 ) ?16 :8 ; + } pbrcnt =sizeof (prescaler) /sizeof (int ); brcnt =sizeof (scaler) /sizeof (int );@@ -259,10 +356,10 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave,for (j =0 ; j < brcnt; j++) { tmp = (baud_speed / scaler[j]) * (1 + dbr); -if (tmp > cfslave->baudrate) - diff = tmp - cfslave->baudrate; +if (tmp > cfspi->baudrate) + diff = tmp - cfspi->baudrate;else - diff = cfslave->baudrate - tmp; + diff = cfspi->baudrate - tmp;if (diff < bestmatch) { bestmatch = diff;@@ -271,65 +368,173 @@ static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, } } } + + bus_setup &= ~(DSPI_CTAR_PBR (0x03 ) |DSPI_CTAR_BR (0x0f )); bus_setup |= (DSPI_CTAR_PBR (best_i) |DSPI_CTAR_BR (best_j)); - dspi->ctar[cfslave->slave.bus] = bus_setup; +writel (bus_setup, &dspi->ctar[bus->seq]); -return &cfslave->slave; +return 0 ; } -#endif /* CONFIG_CF_DSPI */ -#ifdef CONFIG_CMD_SPI -int spi_cs_is_valid (unsigned int bus,unsigned int cs) +static int coldfire_spi_set_mode (struct udevice *bus,uint mode) { -if (((cs >=0 ) && (cs <8 )) && ((bus >=0 ) && (bus <8 ))) -return 1 ; -else -return 0 ; -} +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +u32 bus_setup =0 ; -void spi_init (void ) -{ -cfspi_init (); -} + cfspi->mode = mode; -struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, -unsigned int max_hz,unsigned int mode) -{ -struct cf_spi_slave *cfslave; +if (cfspi->mode &SPI_CPOL ) + bus_setup |=DSPI_CTAR_CPOL ; +if (cfspi->mode &SPI_CPHA ) + bus_setup |=DSPI_CTAR_CPHA ; +if (cfspi->mode &SPI_LSB_FIRST ) + bus_setup |=DSPI_CTAR_LSBFE ; + +/* Overwrite default value set in platform configuration file */ +if (cfspi->mode &SPI_MODE_MOD ) { +if ((cfspi->mode &0xF0000000 ) ==0 ) + bus_setup |= +readl (&dspi->ctar[bus->seq]) &0x78000000 ; +else + bus_setup |= ((cfspi->mode &0xF0000000 ) >>1 ); -if (!spi_cs_is_valid (bus, cs)) -return NULL ; +/* PSCSCK, PASC, PDT */ + bus_setup |= (cfspi->mode &0x0FC00000 ) >>4 ; +/* CSSCK, ASC, DT */ + bus_setup |= (cfspi->mode &0x000FFF00 ) >>4 ; + }else { + bus_setup |= (readl (&dspi->ctar[bus->seq]) &0x78FCFFF0 ); + }Quoted 9 lines
drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 412
Quoted 6 lines
drivers/spi/cf_spi.c +3
-3- cfslave = spi_alloc_slave(struct cf_spi_slave, bus, cs); -if (!cfslave) -return NULL ; + cfspi->charbit = + ((readl (&dspi->ctar[bus->seq]) &0x78000000 ) == +0x78000000 ) ?16 :8 ;Same here?
Ok, done.
Quoted 147 lines
Quoted 134 lines
drivers/spi/cf_spi.c +104
-16- cfslave->baudrate = max_hz; +setbits_be32 (&dspi->ctar[bus->seq], bus_setup); -/* specific setup */ - return cfspi_setup_slave(cfslave, mode); +return 0 ; } -void spi_free_slave (struct spi_slave *slave) +static int coldfire_spi_probe (struct udevice *bus) { -struct cf_spi_slave *cfslave =to_cf_spi_slave (slave); +struct coldfire_spi_platdata *plat =dev_get_platdata (bus); +struct coldfire_spi_priv *cfspi =dev_get_priv (bus); +struct dspi *dspi = cfspi->regs; +int i; -free (cfslave); -} + cfspi->regs = (struct dspi *)plat->regs_addr; + cfspi->gpio_regs = (struct gpio *)MMAP_GPIO ; -int spi_claim_bus (struct spi_slave *slave) -{ -return cfspi_claim_bus (slave->bus, slave->cs); + cfspi->baudrate = plat->speed_hz; + cfspi->mode = plat->mode; + +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) { +unsigned int ctar =0 ; + +if (plat->ctar[i][0 ] ==0 ) +break ; + + ctar =DSPI_CTAR_TRSZ (plat->ctar[i][0 ]) | +DSPI_CTAR_PCSSCK (plat->ctar[i][1 ]) | +DSPI_CTAR_PASC (plat->ctar[i][2 ]) | +DSPI_CTAR_PDT (plat->ctar[i][3 ]) | +DSPI_CTAR_CSSCK (plat->ctar[i][4 ]) | +DSPI_CTAR_ASC (plat->ctar[i][5 ]) | +DSPI_CTAR_DT (plat->ctar[i][6 ]) | +DSPI_CTAR_BR (plat->ctar[i][7 ]); + +writel (ctar, &cfspi->regs->ctar[i]); + } + +/* Default CTARs */ +for (i =0 ; i <MCF_DSPI_MAX_CTAR_REGS ; i++) +writel (MCF_DSPI_DEFAULT_CTAR , &dspi->ctar[i]); + + dspi->mcr =DSPI_MCR_MSTR |DSPI_MCR_CSIS7 |DSPI_MCR_CSIS6 | +DSPI_MCR_CSIS5 |DSPI_MCR_CSIS4 |DSPI_MCR_CSIS3 | +DSPI_MCR_CSIS2 |DSPI_MCR_CSIS1 |DSPI_MCR_CSIS0 | +DSPI_MCR_CRXF |DSPI_MCR_CTXF ; + +return 0 ; } -void spi_release_bus (struct spi_slave *slave) +void spi_init (void ) { -cfspi_release_bus (slave->bus, slave->cs); } -int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout, -void *din,unsigned long flags) +#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) +static int coldfire_dspi_ofdata_to_platdata (struct udevice *bus) { -return cfspi_xfer (slave, bitlen, dout, din, flags); +fdt_addr_t addr; +struct coldfire_spi_platdata *plat = bus->platdata; +const void *blob = gd->fdt_blob; +int node =dev_of_offset (bus); +int *ctar, len; + + addr =devfdt_get_addr (bus); +if (addr ==FDT_ADDR_T_NONE ) +return -ENOMEM ; + + plat->regs_addr = addr; + + plat->num_cs =fdtdec_get_int (blob, node,"num-cs" , +MCF_DSPI_DEFAULT_MAX_CS ); + + plat->speed_hz =fdtdec_get_int (blob, node,"spi-max-frequency" , +MCF_DSPI_DEFAULT_SCK_FREQ ); + + plat->mode =fdtdec_get_int (blob, node,"spi-mode" , +MCF_DSPI_DEFAULT_MODE ); + +memset (plat->ctar,0 ,sizeof (plat->ctar)); + + ctar = (int *)fdt_getprop (blob, node,"ctar-params" , &len); + +if (ctar && len) { +int i, q, ctar_regs; + + ctar_regs = len /sizeof (unsigned int ) /MAX_CTAR_FIELDS ; + +if (ctar_regs >MAX_CTAR_REGS ) + ctar_regs =MAX_CTAR_REGS ; + +for (i =0 ; i < ctar_regs; i++) { +for (q =0 ; q <MAX_CTAR_FIELDS ; q++) + plat->ctar[i][q] = *ctar++; + } + } + +debug ("DSPI: regs=%pa, max-frequency=%d, num-cs=%d, mode=%d\n" , + (void *)plat->regs_addr, + plat->speed_hz, plat->num_cs, plat->mode); + +return 0 ; } -#endif /* CONFIG_CMD_SPI */ + +static const struct udevice_id coldfire_spi_ids[] = { + { .compatible ="fsl,mcf-dspi" }, + { } +}; +#endif + +static const struct dm_spi_ops coldfire_spi_ops = { + .claim_bus = coldfire_spi_claim_bus, + .release_bus = coldfire_spi_release_bus, + .xfer = coldfire_spi_xfer, + .set_speed = coldfire_spi_set_speed, + .set_mode = coldfire_spi_set_mode, +}; + +U_BOOT_DRIVER (coldfire_spi) = { + .name ="spi_coldfire" ,drivers/spi/cf_spi.c static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, · line 540
Quoted 10 lines
drivers/spi/cf_spi.c +10
-0+ .id = UCLASS_SPI, + .probe = coldfire_spi_probe, + .ops = &coldfire_spi_ops, + .platdata_auto_alloc_size = sizeof(struct coldfire_spi_platdata), + .priv_auto_alloc_size =sizeof (struct coldfire_spi_priv ), +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .of_match = coldfire_spi_ids, + .ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata, +#endif +};This has to be as below
Quoted 12 lines
U_BOOT_DRIVER(coldfire_spi)= {
.name = "spi_coldfire",
.id =UCLASS_SPI,
#ifCONFIG_IS_ENABLED(OF_CONTROL)&& !CONFIG_IS_ENABLED(OF_PLATDATA)
.of_match =coldfire_spi_ids,
.ofdata_to_platdata =coldfire_dspi_ofdata_to_platdata,
.platdata_auto_alloc_size =sizeof(struct coldfire_spi_platdata),
#endif
.probe =coldfire_spi_probe,
.ops =&coldfire_spi_ops,
.priv_auto_alloc_size =sizeof(struct coldfire_spi_priv),
};
Quoted 4 lines
Ok, done.
If there are no other points from you, will provide a new version in short.
Just send next version, meanwhile I will look for wait_for_bit will combine while applying.
PATCH v4 8/12 configs: add DM_SPI config option
In reply to Angelo DureghelloThis patch adds CONFIG_DM_SPI for all m68k boards using the cf_spi.c driver (DSPI module).
---
Changes for v2:
- new patch
Changes for v3:
- none
Changes for v4:
- none
--- configs/M52277EVB_defconfig | 1 + configs/M52277EVB_stmicro_defconfig | 1 + configs/M54418TWR_defconfig | 1 + configs/M54418TWR_nand_mii_defconfig | 1 + configs/M54418TWR_nand_rmii_defconfig | 1 + configs/M54418TWR_nand_rmii_lowfreq_defconfig | 1 + configs/M54418TWR_serial_mii_defconfig | 1 + configs/M54418TWR_serial_rmii_defconfig | 1 + configs/M54451EVB_defconfig | 1 + configs/M54451EVB_stmicro_defconfig | 1 + configs/M54455EVB_a66_defconfig | 1 + configs/M54455EVB_defconfig | 1 + configs/M54455EVB_i66_defconfig | 1 + configs/M54455EVB_intel_defconfig | 1 + configs/M54455EVB_stm33_defconfig | 1 + configs/stmark2_defconfig | 2 ++ 16 files changed, 17 insertions(+)
configs/M52277EVB_defconfig +1 -0
@@ -26,4 +26,5 @@ CONFIG_SYS_FLASH_CFI=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M52277EVB_stmicro_defconfig +1 -0
@@ -25,4 +25,5 @@ CONFIG_SYS_FLASH_CFI=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54418TWR_defconfig +1 -0
@@ -26,3 +26,4 @@ CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y CONFIG_CF_SPI=y +CONFIG_DM_SPI=y
configs/M54418TWR_nand_mii_defconfig +1 -0
@@ -24,4 +24,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54418TWR_nand_rmii_defconfig +1 -0
@@ -24,4 +24,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54418TWR_nand_rmii_lowfreq_defconfig +1 -0
@@ -24,4 +24,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54418TWR_serial_mii_defconfig +1 -0
@@ -25,4 +25,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54418TWR_serial_rmii_defconfig +1 -0
@@ -25,4 +25,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54451EVB_defconfig +1 -0
@@ -31,4 +31,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54451EVB_stmicro_defconfig +1 -0
@@ -30,4 +30,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54455EVB_a66_defconfig +1 -0
@@ -35,4 +35,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54455EVB_defconfig +1 -0
@@ -36,4 +36,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54455EVB_i66_defconfig +1 -0
@@ -35,4 +35,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54455EVB_intel_defconfig +1 -0
@@ -35,4 +35,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/M54455EVB_stm33_defconfig +1 -0
@@ -35,4 +35,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_MII=y CONFIG_SPI=y +CONFIG_DM_SPI=y CONFIG_CF_SPI=y
configs/stmark2_defconfig +2 -0
@@ -33,5 +33,7 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_ISSI=y CONFIG_SPI_FLASH_MTD=y CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y CONFIG_CF_SPI=y CONFIG_REGEX=y
Signature · 1 line
2.19.1
PATCH v4 9/12 drivers: serial: mcfuart: add DT support
In reply to Angelo DureghelloThis patch adds devicetree support to the mcfuart.c driver and removes non DM code.
---
Changes for v2:
- remove non DM code
Changes for v3:
- none
Changes for v4:
- none
--- drivers/serial/Kconfig | 8 +++ drivers/serial/mcfuart.c | 106 +++++++++++---------------------------- 2 files changed, 36 insertions(+), 78 deletions(-)
drivers/serial/Kconfig +8 -0
@@ -530,6 +530,14 @@ config MVEBU_A3700_UART Choose this option to add support for UART driver on the Marvell Armada 3700 SoC. The base address is configured via DT. +config MCFUART + bool "Freescale ColdFire UART support" + help + Choose this option to add support for UART driver on the ColdFire + SoC's family. The serial communication channel provides a full-duplex + asynchronous/synchronous receiver and transmitter deriving an + operating frequency from the internal bus clock or an external clock. + config MXC_UART bool "IMX serial port support" depends on MX5 || MX6
drivers/serial/mcfuart.c +28 -78
134 lines not on this page · raw message
Signature · 1 line
2.19.1
PATCH v4 10/12 configs: remove CONFIG_SYS_DSPI_XX references
In reply to Angelo DureghelloThis patch removes CONFIG_SYS_DSPI_XX options from include/configs "m68k" .h board files, since CTAR registers are now set with default values in the cf_spi driver initialization, and configurable by devicetree.
Note, these options cannot be totally removed from the whitelist, since still used from boards using fsl_dspi.c (mostly arm-based boards).
---
Changes for v2:
- new patch
Changes for v3:
- none
Changes for v4:
- none
--- include/configs/M52277EVB.h | 11 ----------- include/configs/M54418TWR.h | 12 ------------ include/configs/M54451EVB.h | 12 ------------ include/configs/M54455EVB.h | 10 ---------- include/configs/stmark2.h | 11 ----------- 5 files changed, 56 deletions(-)
include/configs/M52277EVB.h +0 -11
@@ -103,17 +103,6 @@/* DSPI and Serial Flash */ #define CONFIG_CF_DSPI #define CONFIG_SYS_SBFHDR_SIZE 0x7 -#ifdef CONFIG_CMD_SPI -# define CONFIG_SYS_DSPI_CS2 - -# define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ - DSPI_CTAR_PCSSCK_1CLK | \ - DSPI_CTAR_PASC(0) | \ - DSPI_CTAR_PDT(0) | \ - DSPI_CTAR_CSSCK(0) | \ - DSPI_CTAR_ASC(0) | \ - DSPI_CTAR_DT(1)) -#endif /* Input, PCI, Flexbus, and VCO */ #define CONFIG_EXTRA_CLOCK
include/configs/M54418TWR.h +0 -12
@@ -152,18 +152,6 @@#define CONFIG_CF_DSPI #define CONFIG_SERIAL_FLASH #define CONFIG_SYS_SBFHDR_SIZE 0x7 -#ifdef CONFIG_CMD_SPI - -# define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ - DSPI_CTAR_PCSSCK_1CLK | \ - DSPI_CTAR_PASC(0) | \ - DSPI_CTAR_PDT(0) | \ - DSPI_CTAR_CSSCK(0) | \ - DSPI_CTAR_ASC(0) | \ - DSPI_CTAR_DT(1)) -# define CONFIG_SYS_DSPI_CTAR1 (CONFIG_SYS_DSPI_CTAR0) -# define CONFIG_SYS_DSPI_CTAR2 (CONFIG_SYS_DSPI_CTAR0) -#endif /* Input, PCI, Flexbus, and VCO */ #define CONFIG_EXTRA_CLOCK
include/configs/M54451EVB.h +0 -12
@@ -117,18 +117,6 @@#define CONFIG_CF_DSPI #define CONFIG_SERIAL_FLASH #define CONFIG_SYS_SBFHDR_SIZE 0x7 -#ifdef CONFIG_CMD_SPI - -# define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ - DSPI_CTAR_PCSSCK_1CLK | \ - DSPI_CTAR_PASC(0) | \ - DSPI_CTAR_PDT(0) | \ - DSPI_CTAR_CSSCK(0) | \ - DSPI_CTAR_ASC(0) | \ - DSPI_CTAR_DT(1)) -# define CONFIG_SYS_DSPI_CTAR1 (CONFIG_SYS_DSPI_CTAR0) -# define CONFIG_SYS_DSPI_CTAR2 (CONFIG_SYS_DSPI_CTAR0) -#endif /* Input, PCI, Flexbus, and VCO */ #define CONFIG_EXTRA_CLOCK
include/configs/M54455EVB.h +0 -10
@@ -143,16 +143,6 @@/* DSPI and Serial Flash */ #define CONFIG_CF_DSPI #define CONFIG_SYS_SBFHDR_SIZE 0x13 -#ifdef CONFIG_CMD_SPI - -# define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ - DSPI_CTAR_PCSSCK_1CLK | \ - DSPI_CTAR_PASC(0) | \ - DSPI_CTAR_PDT(0) | \ - DSPI_CTAR_CSSCK(0) | \ - DSPI_CTAR_ASC(0) | \ - DSPI_CTAR_DT(1)) -#endif /* PCI */ #ifdef CONFIG_CMD_PCI
include/configs/stmark2.h +0 -11
@@ -78,17 +78,6 @@#define CONFIG_SYS_SBFHDR_SIZE 0x7 -#define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ - DSPI_CTAR_PCSSCK_1CLK | \ - DSPI_CTAR_PASC(0) | \ - DSPI_CTAR_PDT(0) | \ - DSPI_CTAR_CSSCK(0) | \ - DSPI_CTAR_ASC(0) | \ - DSPI_CTAR_DT(1) | \ - DSPI_CTAR_BR(6)) -#define CONFIG_SYS_DSPI_CTAR1 (CONFIG_SYS_DSPI_CTAR0) -#define CONFIG_SYS_DSPI_CTAR2 (CONFIG_SYS_DSPI_CTAR0) -/* Input, PCI, Flexbus, and VCO */ #define CONFIG_EXTRA_CLOCK
Signature · 1 line
2.19.1
PATCH v4 11/12 m68k: add OF control support to m68k
In reply to Angelo DureghelloAdd SUPPORT_OF_CONTROL at this stage, to avoid to break build bisectability.
---
Changes for v4:
- new patch
--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -28,6 +28,7 @@ config M68K select HAVE_PRIVATE_LIBGCC select SYS_BOOT_GET_CMDLINE select SYS_BOOT_GET_KBD + select SUPPORT_OF_CONTROL config MICROBLAZE bool "MicroBlaze architecture"
Signature · 1 line
2.19.1
PATCH v4 12/12 m68k: move dspi bus control functions into cf_spi.c driver
In reply to Angelo DureghelloThis patches move dspi bus-related operations into more proper location, to avoid the driver to declares them as externs.
---
Changes for v4:
- new patch
--- arch/m68k/cpu/mcf5227x/cpu_init.c | 65 +++----------- arch/m68k/cpu/mcf5445x/cpu_init.c | 142 +++++++----------------------- 2 files changed, 41 insertions(+), 166 deletions(-)
arch/m68k/cpu/mcf5227x/cpu_init.c +11 -54
@@ -16,6 +16,15 @@#include <asm/rtc.h> #include <linux/compiler.h> +void cfspi_port_conf (void ) +{ +gpio_t *gpio = (gpio_t *)MMAP_GPIO ; + +out_8 (&gpio->par_dspi, +GPIO_PAR_DSPI_SIN_SIN |GPIO_PAR_DSPI_SOUT_SOUT | +GPIO_PAR_DSPI_SCK_SCK ); +} +/* * Breath some life into the CPU... *
@@ -93,6 +102,8 @@ void cpu_init_f(void)#endif icache_enable (); + +cfspi_port_conf (); }/*
@@ -137,57 +148,3 @@ void uart_port_conf(int port)break ; } } - -#ifdef CONFIG_CF_DSPI -void cfspi_port_conf (void ) -{ -gpio_t *gpio = (gpio_t *)MMAP_GPIO ; - -out_8 (&gpio->par_dspi, -GPIO_PAR_DSPI_SIN_SIN |GPIO_PAR_DSPI_SOUT_SOUT | -GPIO_PAR_DSPI_SCK_SCK ); -} - -int cfspi_claim_bus (uint bus,uint cs) -{ -dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -gpio_t *gpio = (gpio_t *)MMAP_GPIO ; - -if ((in_be32 (&dspi->sr) &DSPI_SR_TXRXS ) !=DSPI_SR_TXRXS ) -return -1 ; - -/* Clear FIFO and resume transfer */ -clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); - -switch (cs) { -case 0 : -clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_UNMASK ); -setbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); -break ; -case 2 : -clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); -setbits_8 (&gpio->par_timer,GPIO_PAR_TIMER_T2IN_DSPIPCS2 ); -break ; - } - -return 0 ; -} - -void cfspi_release_bus (uint bus,uint cs) -{ -dspi_t *dspi = (dspi_t *)MMAP_DSPI ; -gpio_t *gpio = (gpio_t *)MMAP_GPIO ; - -/* Clear FIFO */ -clrbits_be32 (&dspi->mcr,DSPI_MCR_CTXF |DSPI_MCR_CRXF ); - -switch (cs) { -case 0 : -clrbits_8 (&gpio->par_dspi,GPIO_PAR_DSPI_PCS0_PCS0 ); -break ; -case 2 : -clrbits_8 (&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK ); -break ; - } -} -#endif
arch/m68k/cpu/mcf5445x/cpu_init.c +30 -112
157 lines not on this page · raw message
Signature · 1 line
2.19.1