drivers: Driver support for ADI SC5xx SoCs
Subsystems (11)
cover drivers: Driver support for ADI SC5xx SoCs
This series adds all of the supported peripheral drivers for the sc5xx series of SoCs from Analog Devices and other drivers that are used by the evaluation kits, such as a GPIO expander used by the EZLITE carrier boards.
This series is based on uboot/next as it references the sc5xx machine type at times and currently passes CI.
Greg Malysa (4):
pinctrl: Add support for ADI SC5XX-family pinctrl
gpio: Add support for SC5XX-family processor GPIO driver
net: Add support for ADI SC5xx SoCs with DWC QoS ethernet
dma: Add driver for ADI SC5xx-family SoC MDMA functionality
Nathan Barrett-Morrison (7):
gpio: Add support for ADI ADP5588 GPIO expander chips
usb: musb-new: Add support for Analog Devices SC5xx SoCs
i2c: Add support for ADI SC5XX-family I2C peripheral
watchdog: Add support for ADI SC5XX-family watchdog peripheral
remoteproc: Add in SHARC loading for ADI SC5XX-family processors
spi: Add support for ADI SC5XX-family processor SPI peripherals
mmc: Add support for ADI SC5XX-family processor SDHCI peripherals
MAINTAINERS | 11 + drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/adi_dma.c | 255 +++++++++ drivers/gpio/Kconfig | 17 + drivers/gpio/Makefile | 2 + drivers/gpio/adp5588_gpio.c | 208 ++++++++ drivers/gpio/gpio-adi-adsp.c | 179 +++++++ drivers/i2c/Kconfig | 7 + drivers/i2c/Makefile | 1 + drivers/i2c/adi_i2c.c | 393 ++++++++++++++ drivers/mmc/Kconfig | 8 + drivers/mmc/Makefile | 1 + drivers/mmc/adi_sdhci.c | 152 ++++++ drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 6 + drivers/net/dwc_eth_qos.h | 2 + drivers/net/dwc_eth_qos_adi.c | 101 ++++ drivers/pinctrl/Kconfig | 8 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-adi-adsp.c | 156 ++++++ drivers/remoteproc/Kconfig | 11 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/adi_sc5xx_rproc.c | 276 ++++++++++ drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/adi_spi3.c | 690 +++++++++++++++++++++++++ drivers/usb/musb-new/Kconfig | 7 + drivers/usb/musb-new/Makefile | 1 + drivers/usb/musb-new/sc5xx.c | 202 ++++++++ drivers/watchdog/Kconfig | 9 + drivers/watchdog/Makefile | 1 + drivers/watchdog/adi_wdt.c | 145 ++++++ include/dt-bindings/pinctrl/adi-adsp.h | 21 + 35 files changed, 2895 insertions(+) create mode 100644 drivers/dma/adi_dma.c create mode 100644 drivers/gpio/adp5588_gpio.c create mode 100644 drivers/gpio/gpio-adi-adsp.c create mode 100644 drivers/i2c/adi_i2c.c create mode 100644 drivers/mmc/adi_sdhci.c create mode 100644 drivers/net/dwc_eth_qos_adi.c create mode 100644 drivers/pinctrl/pinctrl-adi-adsp.c create mode 100644 drivers/remoteproc/adi_sc5xx_rproc.c create mode 100644 drivers/spi/adi_spi3.c create mode 100644 drivers/usb/musb-new/sc5xx.c create mode 100644 drivers/watchdog/adi_wdt.c create mode 100644 include/dt-bindings/pinctrl/adi-adsp.h
Signature · 1 line
2.43.2
PATCH 1/11 pinctrl: Add support for ADI SC5XX-family pinctrl
This adds support for pin configuration on the Analog Devices SC5XX SoC family. This commit is largely a port of the Linux driver, which has not yet been submitted upstream.
---
--- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 8 ++ drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-adi-adsp.c | 156 +++++++++++++++++++++++++ include/dt-bindings/pinctrl/adi-adsp.h | 21 ++++ 5 files changed, 187 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-adi-adsp.c create mode 100644 include/dt-bindings/pinctrl/adi-adsp.h
MAINTAINERS +1 -0
@@ -610,6 +610,7 @@ T: git https://github.com/analogdevicesinc/lnxdsp-u-boot F: arch/arm/include/asm/arch-adi/ F: arch/arm/mach-sc5xx/ F: drivers/clk/adi/ +F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c F: include/env/adi/
drivers/pinctrl/Kconfig +8 -0
@@ -170,6 +170,14 @@ config PINCTRL_APPLE both the GPIO definitions and pin control functions for each available multiplex function. +config PINCTRL_ADI + bool "ADI pinctrl driver" + depends on DM && (SC57X || SC58X || SC59X || SC59X_64) + help + This driver enables pinctrl support on SC5xx processors. This + driver covers only the pin configuration functionality, and + GPIO functionality is contained in the separate GPIO driver. + config PINCTRL_AR933X bool "QCA/Athores ar933x pin control driver" depends on DM && SOC_AR933X
drivers/pinctrl/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-y += pinctrl-uclass.o obj-$(CONFIG_$(SPL_)PINCTRL_GENERIC) += pinctrl-generic.o +obj-$(CONFIG_PINCTRL_ADI) += pinctrl-adi-adsp.o obj-$(CONFIG_PINCTRL_APPLE) += pinctrl-apple.o obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o
drivers/pinctrl/pinctrl-adi-adsp.c new file +156 -0
156 lines not on this page · raw message
include/dt-bindings/pinctrl/adi-adsp.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* (C) Copyright 2022 - Analog Devices, Inc. +* +* Written and/or maintained by Timesys Corporation +* +* Contact: Nathan Barrett-Morrison <[email protected]> +* Contact: Greg Malysa <[email protected]> +* +*/ + +#ifndef DT_BINDINGS_PINCTRL_ADI_ADSP +#define DT_BINDINGS_PINCTRL_ADI_ADSP + +#define ADI_ADSP_PIN (port, pin) (16 * ((port) - 'A') + (pin)) +#define ADI_ADSP_PINFUNC_ALT0 0 +#define ADI_ADSP_PINFUNC_ALT1 1 +#define ADI_ADSP_PINFUNC_ALT2 2 +#define ADI_ADSP_PINFUNC_ALT3 3 + +#endif
Signature · 1 line
2.43.2
PATCH 2/11 gpio: Add support for SC5XX-family processor GPIO driver
In reply to Greg MalysaThis adds support for using the GPIO pins on the SC5XX family of SoCs from Analog Devices.
---
MAINTAINERS | 1 + drivers/gpio/Kconfig | 9 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-adi-adsp.c | 179 +++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpio/gpio-adi-adsp.c
MAINTAINERS +1 -0
@@ -610,6 +610,7 @@ T: git https://github.com/analogdevicesinc/lnxdsp-u-boot F: arch/arm/include/asm/arch-adi/ F: arch/arm/mach-sc5xx/ F: drivers/clk/adi/ +F: drivers/gpio/gpio-adi-adsp.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c
drivers/gpio/Kconfig +9 -0
@@ -97,6 +97,15 @@ config SPL_DM_GPIO_LOOKUP_LABEL different gpios on different hardware versions for the same functionality in board code. +config ADI_GPIO + bool "ADI GPIO driver" + depends on DM_GPIO && (SC57X || SC58X || SC59X || SC59X_64) + help + This driver supports GPIO banks on SC5xx processors. It + supports inputs and outputs but does not support pin + interrupt functionality (PINT) or other features in the + Linux version of the driver. + config ALTERA_PIO bool "Altera PIO driver" depends on DM_GPIO
drivers/gpio/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_$(SPL_TPL_)DM_GPIO) += gpio-uclass.o obj-$(CONFIG_$(SPL_)DM_PCA953X) += pca953x_gpio.o +obj-$(CONFIG_ADI_GPIO) += gpio-adi-adsp.o obj-$(CONFIG_ASPEED_GPIO) += gpio-aspeed.o obj-$(CONFIG_AT91_GPIO) += at91_gpio.o obj-$(CONFIG_ATMEL_PIO4) += atmel_pio4.o
drivers/gpio/gpio-adi-adsp.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 3/11 gpio: Add support for ADI ADP5588 GPIO expander chips
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
This adds support for the ADP588 GPIO expander from Analog Devices. It is accessed over I2C and provides up to 18 pins. It is largely a port of the Linux driver developed by Michael Hennerich <[email protected]>
---
MAINTAINERS | 1 + drivers/gpio/Kconfig | 8 ++ drivers/gpio/Makefile | 1 + drivers/gpio/adp5588_gpio.c | 208 ++++++++++++++++++++++++++++++++++++ 4 files changed, 218 insertions(+) create mode 100644 drivers/gpio/adp5588_gpio.c
MAINTAINERS +1 -0
@@ -610,6 +610,7 @@ T: git https://github.com/analogdevicesinc/lnxdsp-u-boot F: arch/arm/include/asm/arch-adi/ F: arch/arm/mach-sc5xx/ F: drivers/clk/adi/ +F: drivers/gpio/adp5588_gpio.c F: drivers/gpio/gpio-adi-adsp.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c
drivers/gpio/Kconfig +8 -0
@@ -531,6 +531,14 @@ config DM_PCA953X Now, max 24 bits chips and PCA953X compatible chips are supported +config ADP5588_GPIO + bool "ADP5588 GPIO expander driver" + depends on DM_GPIO && DM_I2C + help + Say yes here to support GPIO functionality of ADI ADP5588 chips. + + The ADP5588 is an 18-port I2C GPIO expander and keypad controller. + config SPL_DM_PCA953X bool "PCA95[357]x, PCA9698, TCA64xx, and MAX7310 I/O ports in SPL" depends on SPL_DM_GPIO
drivers/gpio/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_NOMADIK_GPIO) += nmk_gpio.o obj-$(CONFIG_MAX7320_GPIO) += max7320_gpio.o obj-$(CONFIG_$(SPL_)MAX77663_GPIO) += max77663_gpio.o obj-$(CONFIG_SL28CPLD_GPIO) += sl28cpld-gpio.o +obj-$(CONFIG_ADP5588_GPIO) += adp5588_gpio.o obj-$(CONFIG_ZYNQMP_GPIO_MODEPIN) += zynqmp_gpio_modepin.o obj-$(CONFIG_SLG7XL45106_I2C_GPO) += gpio_slg7xl45106.o obj-$(CONFIG_FTGPIO010) += ftgpio010.o
drivers/gpio/adp5588_gpio.c new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 4/11 usb: musb-new: Add support for Analog Devices SC5xx SoCs
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
This adds support for the MUSB-based USB controller found in the Analog Devices SC57x and SC58x SoCs.
---
MAINTAINERS | 1 + drivers/usb/musb-new/Kconfig | 7 ++ drivers/usb/musb-new/Makefile | 1 + drivers/usb/musb-new/sc5xx.c | 202 ++++++++++++++++++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 drivers/usb/musb-new/sc5xx.c
MAINTAINERS +1 -0
@@ -615,6 +615,7 @@ F: drivers/gpio/gpio-adi-adsp.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c +F: drivers/usb/musb-new/sc5xx.c F: include/env/adi/ ARM SNAPDRAGON
drivers/usb/musb-new/Kconfig +7 -0
@@ -22,6 +22,13 @@ config USB_MUSB_GADGET Enables the MUSB USB dual-role controller in gadget mode. if USB_MUSB_HOST || USB_MUSB_GADGET +config USB_MUSB_SC5XX + bool "Analog Devices MUSB support" + depends on (SC57X || SC58X) + help + Say y here to enable support for the USB controller on + ADI SC57X/SC58X processors. + config USB_MUSB_DA8XX bool "Enable DA8xx MUSB Controller" depends on ARCH_DAVINCI
drivers/usb/musb-new/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_MUSB_PIC32) += pic32.o obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o obj-$(CONFIG_USB_MUSB_TI) += ti-musb.o obj-$(CONFIG_USB_MUSB_UX500) += ux500.o +obj-$(CONFIG_USB_MUSB_SC5XX) += sc5xx.o ccflags-y := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \
drivers/usb/musb-new/sc5xx.c new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 5/11 i2c: Add support for ADI SC5XX-family I2C peripheral
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
---
MAINTAINERS | 1 + drivers/i2c/Kconfig | 7 + drivers/i2c/Makefile | 1 + drivers/i2c/adi_i2c.c | 393 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 402 insertions(+) create mode 100644 drivers/i2c/adi_i2c.c
MAINTAINERS +1 -0
@@ -612,6 +612,7 @@ F: arch/arm/mach-sc5xx/ F: drivers/clk/adi/ F: drivers/gpio/adp5588_gpio.c F: drivers/gpio/gpio-adi-adsp.c +F: drivers/i2c/adi_i2c.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c
drivers/i2c/Kconfig +7 -0
@@ -154,6 +154,13 @@ config SPL_DM_I2C_GPIO bindings are supported. Binding info: doc/device-tree-bindings/i2c/i2c-gpio.txt +config SYS_I2C_ADI + bool "ADI I2C driver" + depends on DM_I2C && (SC57X || SC58X || SC59X || SC59X_64) + help + Add support for the ADI (Analog Devices) I2C driver as used + in SC57X, SC58X, SC59X, SC59X_64. + config SYS_I2C_AT91 bool "Atmel I2C driver" depends on DM_I2C && ARCH_AT91
drivers/i2c/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_$(SPL_)I2C_CROS_EC_TUNNEL) += cros_ec_tunnel.o obj-$(CONFIG_$(SPL_)I2C_CROS_EC_LDO) += cros_ec_ldo.o obj-$(CONFIG_$(SPL_)SYS_I2C_LEGACY) += i2c_core.o +obj-$(CONFIG_SYS_I2C_ADI) += adi_i2c.o obj-$(CONFIG_SYS_I2C_ASPEED) += ast_i2c.o obj-$(CONFIG_SYS_I2C_AST2600) += ast2600_i2c.o obj-$(CONFIG_SYS_I2C_AT91) += at91_i2c.o
drivers/i2c/adi_i2c.c new file +393 -0
393 lines not on this page · raw message
Signature · 1 line
2.43.2
Re: [PATCH 05/11] i2c: Add support for ADI SC5XX-family I2C peripheral
Hello Greg,
Quoted 12 lines · Greg Malysa
From: Nathan Barrett-Morrison <[email protected]>
Co-developed-by Greg Malysa <[email protected]>Signed-off-by Greg Malysa <[email protected]>Co-developed-by Ian Roberts <[email protected]>Signed-off-by Ian Roberts <[email protected]>Co-developed-by Angelo Dureghello <[email protected]>Signed-off-by Angelo Dureghello <[email protected]>Signed-off-by Vasileios Bimpikas <[email protected]>Signed-off-by Utsav Agarwal <[email protected]>Signed-off-by Arturs Artamonovs <[email protected]>Signed-off-by Nathan Barrett-Morrison <[email protected]>
Quoted 8 lines
---
MAINTAINERS | 1 + drivers/i2c/Kconfig | 7 + drivers/i2c/Makefile | 1 + drivers/i2c/adi_i2c.c | 393 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 402 insertions(+)create mode 100644
drivers/i2c/adi_i2c.c
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
PATCH 6/11 net: Add support for ADI SC5xx SoCs with DWC QoS ethernet
In reply to Greg MalysaThe ADI SC598 includes a Designware QoS 5.20a IP block. This commit adds support for using the existing ethernet QoS driver with the SC598 SoC.
---
MAINTAINERS | 1 + drivers/net/Kconfig | 7 +++ drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 6 ++ drivers/net/dwc_eth_qos.h | 2 + drivers/net/dwc_eth_qos_adi.c | 101 ++++++++++++++++++++++++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 drivers/net/dwc_eth_qos_adi.c
MAINTAINERS +1 -0
@@ -613,6 +613,7 @@ F: drivers/clk/adi/ F: drivers/gpio/adp5588_gpio.c F: drivers/gpio/gpio-adi-adsp.c F: drivers/i2c/adi_i2c.c +F: drivers/net/dwc_eth_qos_adi.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c
drivers/net/Kconfig +7 -0
@@ -236,6 +236,13 @@ config DWC_ETH_QOS Of Service) IP block. The IP supports many options for bus type, clocking/reset structure, and feature list. +config DWC_ETH_QOS_ADI + bool "Synopsys DWC Ethernet QOS device support for ADI SC59x-64 parts" + depends on DWC_ETH_QOS + help + The Synopsis Designware Ethernet QoS IP block with the specific + configuration used in the ADI ADSP-SC59X 64 bit SoCs + config DWC_ETH_QOS_IMX bool "Synopsys DWC Ethernet QOS device support for IMX" depends on DWC_ETH_QOS
drivers/net/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o +obj-$(CONFIG_DWC_ETH_QOS_ADI) += dwc_eth_qos_adi.o obj-$(CONFIG_DWC_ETH_QOS_IMX) += dwc_eth_qos_imx.o obj-$(CONFIG_DWC_ETH_QOS_ROCKCHIP) += dwc_eth_qos_rockchip.o obj-$(CONFIG_DWC_ETH_QOS_QCOM) += dwc_eth_qos_qcom.o
drivers/net/dwc_eth_qos.c +6 -0
@@ -1544,6 +1544,12 @@ static const struct udevice_id eqos_ids[] = { .compatible = "starfive,jh7110-dwmac", .data = (ulong)&eqos_jh7110_config }, +#endif +#if IS_ENABLED (CONFIG_DWC_ETH_QOS_ADI ) + { + .compatible = "adi,sc59x-dwmac-eqos", + .data = (ulong)&eqos_adi_config + },#endif { } };
drivers/net/dwc_eth_qos.h +2 -0
@@ -84,6 +84,7 @@ struct eqos_mac_regs {#define EQOS_MAC_MDIO_ADDRESS_CR_SHIFT 8#define EQOS_MAC_MDIO_ADDRESS_CR_100_150 1#define EQOS_MAC_MDIO_ADDRESS_CR_20_35 2 +#define EQOS_MAC_MDIO_ADDRESS_CR_150_250 4#define EQOS_MAC_MDIO_ADDRESS_CR_250_300 5#define EQOS_MAC_MDIO_ADDRESS_SKAP BIT(4)#define EQOS_MAC_MDIO_ADDRESS_GOC_SHIFT 2
@@ -293,3 +294,4 @@ extern struct eqos_config eqos_qcom_config;extern struct eqos_config eqos_stm32mp13_config;extern struct eqos_config eqos_stm32mp15_config;extern struct eqos_config eqos_jh7110_config; +extern struct eqos_config eqos_adi_config;
drivers/net/dwc_eth_qos_adi.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 7/11 watchdog: Add support for ADI SC5XX-family watchdog peripheral
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
---
MAINTAINERS | 1 + drivers/watchdog/Kconfig | 9 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/adi_wdt.c | 145 +++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 drivers/watchdog/adi_wdt.c
MAINTAINERS +1 -0
@@ -618,6 +618,7 @@ F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c F: drivers/usb/musb-new/sc5xx.c +F: drivers/watchdog/adi_wdt.c F: include/env/adi/ ARM SNAPDRAGON
drivers/watchdog/Kconfig +9 -0
@@ -94,6 +94,15 @@ config WDT_APPLE The watchdog will perform a full SoC reset resulting in a reboot of the entire system. +config WDT_ADI + bool "Analog Devices watchdog timer support" + select WDT + select SPL_WDT if SPL + depends on (SC57X || SC58X || SC59X || SC59X_64) + help + Enable this to support Watchdog Timer on ADI SC57X, SC58X, SC59X, + and SC59X_64 processors + config WDT_ARMADA_37XX bool "Marvell Armada 37xx watchdog timer support" depends on WDT && ARMADA_3700
drivers/watchdog/Makefile +1 -0
@@ -50,3 +50,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o +obj-$(CONFIG_WDT_ADI) += adi_wdt.o
drivers/watchdog/adi_wdt.c new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.43.2
Re: [PATCH 07/11] watchdog: Add support for ADI SC5XX-family watchdog peripheral
Quoted 10 lines · Greg Malysa
From: Nathan Barrett-Morrison <[email protected]>
Co-developed-by Greg Malysa <[email protected]>Signed-off-by Greg Malysa <[email protected]>Co-developed-by Ian Roberts <[email protected]>Signed-off-by Ian Roberts <[email protected]>Signed-off-by Vasileios Bimpikas <[email protected]>Signed-off-by Utsav Agarwal <[email protected]>Signed-off-by Arturs Artamonovs <[email protected]>Signed-off-by Nathan Barrett-Morrison <[email protected]>
Quoted 8 lines
---
MAINTAINERS | 1 + drivers/watchdog/Kconfig | 9 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/adi_wdt.c | 145 +++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+)create mode 100644
drivers/watchdog/adi_wdt.c
Thanks,
Stefan
Quoted 182 lines
MAINTAINERS +1
-0@@ -618,6 +618,7 @@ F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c F: drivers/usb/musb-new/sc5xx.c +F: drivers/watchdog/adi_wdt.c F: include/env/adi/ ARM SNAPDRAGONdrivers/watchdog/Kconfig +9
-0@@ -94,6 +94,15 @@ config WDT_APPLE The watchdog will perform a full SoC reset resulting in a reboot of the entire system. +config WDT_ADI + bool "Analog Devices watchdog timer support" + select WDT + select SPL_WDT if SPL + depends on (SC57X || SC58X || SC59X || SC59X_64) + help + Enable this to support Watchdog Timer on ADI SC57X, SC58X, SC59X, + and SC59X_64 processors + config WDT_ARMADA_37XX bool "Marvell Armada 37xx watchdog timer support" depends on WDT && ARMADA_3700drivers/watchdog/Makefile +1
-0@@ -50,3 +50,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o +obj-$(CONFIG_WDT_ADI) += adi_wdt.odrivers/watchdog/adi_wdt.c new file +135
-0@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (C) Copyright 2022 - Analog Devices, Inc. +* +* Written and/or maintained by Timesys Corporation +* +* Converted to driver model by Nathan Barrett-Morrison +* +* Contact: Nathan Barrett-Morrison <[email protected]> +* Contact: Greg Malysa <[email protected]> +* +* adi_wtd.c - driver for ADI on-chip watchdog +* +*/ + +#include <clk.h> +#include <dm.h> +#include <wdt.h> +#include <linux/delay.h> +#include <linux/ioport.h> +#include <linux/io.h> + +#define WDOG_CTL 0x0 +#define WDOG_CNT 0x4 +#define WDOG_STAT 0x8 + +#define RCU_CTL 0x0 +#define RCU_STAT 0x4 + +#define SEC_GCTL 0x0 +#define SEC_FCTL 0x10 +#define SEC_SCTL0 0x800 + +#define WDEN 0x0010 +#define WDDIS 0x0AD0 + +struct adi_wdt_priv { +void __iomem *rcu_base; +void __iomem *sec_base; +void __iomem *wdt_base; +struct clk clock; +}; + +static int adi_wdt_reset (struct udevice *dev) +{ +struct adi_wdt_priv *priv =dev_get_priv (dev); + +writel (0 , priv->wdt_base +WDOG_STAT ); + +return 0 ; +} + +static int adi_wdt_start (struct udevice *dev,u64 timeout_ms,ulong flags) +{ +struct adi_wdt_priv *priv =dev_get_priv (dev); +u32 sctl_val; + +/* Disable SYSCD_RESETb input and clear the RCU0 reset status */ +writel (0xf , priv->rcu_base +RCU_STAT ); +writel (0x0 , priv->rcu_base +RCU_CTL ); + +/* reset the SEC controller */ +writel (0x2 , priv->sec_base +SEC_GCTL ); +writel (0x2 , priv->sec_base +SEC_FCTL ); + +udelay (50 ); + +/* enable SEC fault event */ +writel (0x1 , priv->sec_base +SEC_GCTL ); + +/* ANOMALY 36100004 Spurious External Fault event occurs when FCTL +* is re-programmed when currently active fault is not cleared +*/ +writel (0xc0 , priv->sec_base +SEC_FCTL ); +writel (0xc1 , priv->sec_base +SEC_FCTL ); + +/* enable SEC fault source for watchdog0 */ + sctl_val =readl ((priv->sec_base +SEC_SCTL0 ) +3 *8 ) |0x6 ; +writel (sctl_val, (priv->sec_base +SEC_SCTL0 ) +3 *8 ); + +/* Enable SYSCD_RESETb input */ +writel (0x100 , priv->rcu_base +RCU_CTL ); + +/* enable watchdog0 */ +writel (WDDIS , priv->wdt_base +WDOG_CTL ); + +writel (timeout_ms /1000 * + (clk_get_rate (&priv->clock) / (IS_ENABLED (CONFIG_SC58X ) ?2 :1 )), + priv->wdt_base +WDOG_CNT ); + +writel (0 , priv->wdt_base +WDOG_STAT ); +writel (WDEN , priv->wdt_base +WDOG_CTL ); + +return 0 ; +} + +static int adi_wdt_probe (struct udevice *dev) +{ +struct adi_wdt_priv *priv =dev_get_priv (dev); +int ret; +struct resource res; + + ret =dev_read_resource_byname (dev,"rcu" , &res); +if (ret) +return ret; + priv->rcu_base =devm_ioremap (dev, res.start,resource_size (&res)); + + ret =dev_read_resource_byname (dev,"sec" , &res); +if (ret) +return ret; + priv->sec_base =devm_ioremap (dev, res.start,resource_size (&res)); + + ret =dev_read_resource_byname (dev,"wdt" , &res); +if (ret) +return ret; + priv->wdt_base =devm_ioremap (dev, res.start,resource_size (&res)); + + ret =clk_get_by_name (dev,"sclk0" , &priv->clock); +if (ret <0 ) { +printf ("Can't get WDT clk: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static const struct wdt_ops adi_wdt_ops = { + .start = adi_wdt_start, + .reset = adi_wdt_reset, +}; + +static const struct udevice_id adi_wdt_ids[] = { + { .compatible ="adi,wdt" }, + {} +};
drivers/watchdog/adi_wdt.c line 145
Quoted 10 lines
drivers/watchdog/adi_wdt.c new file +10
-0+ +U_BOOT_DRIVER (adi_wdt) = { + .name ="adi_wdt" , + .id =UCLASS_WDT , + .of_match = adi_wdt_ids, + .probe = adi_wdt_probe, + .ops = &adi_wdt_ops, + .priv_auto =sizeof (struct adi_wdt_priv ), + .flags =DM_FLAG_PRE_RELOC , +};
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH 8/11 dma: Add driver for ADI SC5xx-family SoC MDMA functionality
In reply to Greg MalysaAdd a rudimentary MDMA driver for the Analog Devices SC5xx SoCs, primarily intended for use with and tested against the QSPI/OSPI IP included in the SoC.
---
MAINTAINERS | 1 + drivers/dma/Kconfig | 7 ++ drivers/dma/Makefile | 1 + drivers/dma/adi_dma.c | 255 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 drivers/dma/adi_dma.c
MAINTAINERS +1 -0
@@ -610,6 +610,7 @@ T: git https://github.com/analogdevicesinc/lnxdsp-u-boot F: arch/arm/include/asm/arch-adi/ F: arch/arm/mach-sc5xx/ F: drivers/clk/adi/ +F: drivers/dma/adi_dma.c F: drivers/gpio/adp5588_gpio.c F: drivers/gpio/gpio-adi-adsp.c F: drivers/i2c/adi_i2c.c
drivers/dma/Kconfig +7 -0
@@ -76,6 +76,13 @@ config XILINX_DPDMA this file is used as placeholder for driver. The main reason is to record compatible string and calling power domain driver. +config ADI_DMA + bool "ADI DMA driver" + depends on DMA && DMA_CHANNELS + help + Enable DMA support for Analog Devices SOCs, such as the SC5xx. + Currently this is a minimalistic driver tested against OSPI use only. + if APBH_DMA config APBH_DMA_BURST bool "Enable DMA BURST"
drivers/dma/Makefile +1 -0
@@ -13,5 +13,6 @@ obj-$(CONFIG_TI_KSNAV) += keystone_nav.o keystone_nav_cfg.o obj-$(CONFIG_TI_EDMA3) += ti-edma3.o obj-$(CONFIG_DMA_LPC32XX) += lpc32xx_dma.o obj-$(CONFIG_XILINX_DPDMA) += xilinx_dpdma.o +obj-$(CONFIG_ADI_DMA) += adi_dma.o obj-y += ti/
drivers/dma/adi_dma.c new file +255 -0
255 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 9/11 remoteproc: Add in SHARC loading for ADI SC5XX-family processors
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
This adds the ability to load ldr-formatted files to the SHARC coprocessors using the rproc interface. Only a minimal subset of rproc functionality is supported: loading and starting the remote core.
Secure boot and signed ldr verification are not available at this time through the U-Boot interface.
---
MAINTAINERS | 1 + drivers/remoteproc/Kconfig | 11 ++ drivers/remoteproc/Makefile | 1 + drivers/remoteproc/adi_sc5xx_rproc.c | 276 +++++++++++++++++++++++++++ 4 files changed, 289 insertions(+) create mode 100644 drivers/remoteproc/adi_sc5xx_rproc.c
MAINTAINERS +1 -0
@@ -616,6 +616,7 @@ F: drivers/gpio/gpio-adi-adsp.c F: drivers/i2c/adi_i2c.c F: drivers/net/dwc_eth_qos_adi.c F: drivers/pinctrl/pinctrl-adi-adsp.c +F: drivers/remoteproc/adi_sc5xx_rproc.c F: drivers/serial/serial_adi_uart4.c F: drivers/timer/adi_sc5xx_timer.c F: drivers/usb/musb-new/sc5xx.c
drivers/remoteproc/Kconfig +11 -0
@@ -13,6 +13,7 @@ config REMOTEPROC depends on DM # Please keep the configuration alphabetically sorted. + config K3_SYSTEM_CONTROLLER bool "Support for TI' K3 System Controller" select REMOTEPROC
@@ -22,6 +23,16 @@ config K3_SYSTEM_CONTROLLER help Say 'y' here to add support for TI' K3 System Controller. +config REMOTEPROC_ADI_SC5XX + bool "Support for ADI SC5xx SHARC cores" + select REMOTEPROC + depends on DM + depends on ARCH_SC5XX + depends on SYSCON + help + Say 'y' here to add support for loading code onto SHARC cores in + an ADSP-SC5xx SoC from Analog Devices + config REMOTEPROC_SANDBOX bool "Support for Test processor for Sandbox" select REMOTEPROC
drivers/remoteproc/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_$(SPL_)REMOTEPROC) += rproc-uclass.o rproc-elf-loader.o # Remote proc drivers - Please keep this list alphabetically sorted. obj-$(CONFIG_K3_SYSTEM_CONTROLLER) += k3_system_controller.o +obj-$(CONFIG_REMOTEPROC_ADI_SC5XX) += adi_sc5xx_rproc.o obj-$(CONFIG_REMOTEPROC_SANDBOX) += sandbox_testproc.o obj-$(CONFIG_REMOTEPROC_STM32_COPRO) += stm32_copro.o obj-$(CONFIG_REMOTEPROC_TI_K3_ARM64) += ti_k3_arm64_rproc.o
drivers/remoteproc/adi_sc5xx_rproc.c new file +276 -0
276 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 10/11 spi: Add support for ADI SC5XX-family processor SPI peripherals
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
This adds support for the ADI-specific SPI driver present in the ADI SC5xx line of SoCs. This IP block is distinct from the QSPI/OSPI block that uses the Cadence driver. Both may be used at once with appropriate pin muxing configuration.
---
MAINTAINERS | 1 + drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/adi_spi3.c | 690 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 698 insertions(+) create mode 100644 drivers/spi/adi_spi3.c
MAINTAINERS +1 -0
@@ -618,6 +618,7 @@ F: drivers/net/dwc_eth_qos_adi.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/remoteproc/adi_sc5xx_rproc.c F: drivers/serial/serial_adi_uart4.c +F: drivers/spi/adi_spi3.c F: drivers/timer/adi_sc5xx_timer.c F: drivers/usb/musb-new/sc5xx.c F: drivers/watchdog/adi_wdt.c
drivers/spi/Kconfig +6 -0
@@ -52,6 +52,12 @@ config SPI_DIRMAP if DM_SPI +config ADI_SPI3 + bool "Enable ADI SPI Driver" + help + Enable the ADI (Analog Devices) SPI controller driver. This + driver enables the support for SC5XX spi controller. + config ALTERA_SPI bool "Altera SPI driver" help
drivers/spi/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-y += spi.o obj-$(CONFIG_SPI_MEM) += spi-mem-nodm.o endif +obj-$(CONFIG_ADI_SPI3) += adi_spi3.o obj-$(CONFIG_ALTERA_SPI) += altera_spi.o obj-$(CONFIG_APPLE_SPI) += apple_spi.o obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
drivers/spi/adi_spi3.c new file +690 -0
690 lines not on this page · raw message
Signature · 1 line
2.43.2
Re: [PATCH 10/11] spi: Add support for ADI SC5XX-family processor SPI peripherals
Le 15/05/2024 à 23:57, Greg Malysa a écrit :
Quoted 327 lines
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
From: Nathan Barrett-Morrison <[email protected]>
This adds support for the ADI-specific SPI driver present in the ADI SC5xx line of SoCs. This IP block is distinct from the QSPI/OSPI block that uses the Cadence driver. Both may be used at once with appropriate pin muxing configuration.
Co-developed-by Greg Malysa <[email protected]>Signed-off-by Greg Malysa <[email protected]>Co-developed-by Angelo Dureghello <[email protected]>Signed-off-by Angelo Dureghello <[email protected]>Co-developed-by Ian Roberts <[email protected]>Signed-off-by Ian Roberts <[email protected]>Co-developed-by Piotr Wojtaszczyk <[email protected]>Signed-off-by Piotr Wojtaszczyk <[email protected]>Signed-off-by Vasileios Bimpikas <[email protected]>Signed-off-by Utsav Agarwal <[email protected]>Signed-off-by Arturs Artamonovs <[email protected]>Signed-off-by Nathan Barrett-Morrison <[email protected]>---
MAINTAINERS | 1 + drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/adi_spi3.c | 690 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 698 insertions(+)create mode 100644
drivers/spi/adi_spi3.cMAINTAINERS +1
-0@@ -618,6 +618,7 @@ F: drivers/net/dwc_eth_qos_adi.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/remoteproc/adi_sc5xx_rproc.c F: drivers/serial/serial_adi_uart4.c +F: drivers/spi/adi_spi3.c F: drivers/timer/adi_sc5xx_timer.c F: drivers/usb/musb-new/sc5xx.c F: drivers/watchdog/adi_wdt.cdrivers/spi/Kconfig +6
-0@@ -52,6 +52,12 @@ config SPI_DIRMAP if DM_SPI +config ADI_SPI3 + bool "Enable ADI SPI Driver" + help + Enable the ADI (Analog Devices) SPI controller driver. This + driver enables the support for SC5XX spi controller. + config ALTERA_SPI bool "Altera SPI driver" helpdrivers/spi/Makefile +1
-0@@ -19,6 +19,7 @@ obj-y += spi.o obj-$(CONFIG_SPI_MEM) += spi-mem-nodm.o endif +obj-$(CONFIG_ADI_SPI3) += adi_spi3.o obj-$(CONFIG_ALTERA_SPI) += altera_spi.o obj-$(CONFIG_APPLE_SPI) += apple_spi.o obj-$(CONFIG_ATH79_SPI) += ath79_spi.odrivers/spi/adi_spi3.c new file +250
-0@@ -0,0 +1,690 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (C) Copyright 2022 - Analog Devices, Inc. +* +* Written and/or maintained by Timesys Corporation +* +* Converted to driver model by Nathan Barrett-Morrison +* +* Contact: Nathan Barrett-Morrison <[email protected]> +* Contact: Greg Malysa <[email protected]> +* Contact: Ian Roberts <[email protected]> +* Contact: Piotr Wojtaszczyk <[email protected]> +* +*/ + +#include <clk.h> +#include <dm.h> +#include <spi.h> +#include <spi-mem.h> +#include <asm/io.h> +#include <dm/device_compat.h> + +#define SPI_IDLE_VAL 0xff + +#define MAX_CTRL_CS 7 + +/* SPI_CONTROL */ +#define SPI_CTL_EN 0x00000001/* Enable */ +#define SPI_CTL_MSTR 0x00000002/* Master/Slave */ +#define SPI_CTL_PSSE 0x00000004/* controls modf error in master mode */ +#define SPI_CTL_ODM 0x00000008/* Open Drain Mode */ +#define SPI_CTL_CPHA 0x00000010/* Clock Phase */ +#define SPI_CTL_CPOL 0x00000020/* Clock Polarity */ +#define SPI_CTL_ASSEL 0x00000040/* Slave Select Pin Control */ +#define SPI_CTL_SELST 0x00000080/* Slave Select Polarity in transfers */ +#define SPI_CTL_EMISO 0x00000100/*Enable MISO */ +#define SPI_CTL_SIZE 0x00000600/*Word Transfer Size */ +#define SPI_CTL_SIZE08 0x00000000/*SIZE: 8 bits */ +#define SPI_CTL_SIZE16 0x00000200/*SIZE: 16 bits */ +#define SPI_CTL_SIZE32 0x00000400/*SIZE: 32 bits */ +#define SPI_CTL_LSBF 0x00001000/*LSB First */ +#define SPI_CTL_FCEN 0x00002000/*Flow-Control Enable */ +#define SPI_CTL_FCCH 0x00004000/*Flow-Control Channel Selection */ +#define SPI_CTL_FCPL 0x00008000/*Flow-Control Polarity */ +#define SPI_CTL_FCWM 0x00030000/*Flow-Control Water-Mark */ +#define SPI_CTL_FIFO0 0x00000000/*FCWM: Tx empty or Rx Full */ +#define SPI_CTL_FIFO1 0x00010000/*FCWM: Tx empty or Rx full (>=75%) */ +#define SPI_CTL_FIFO2 0x00020000/*FCWM: Tx empty or Rx full (>=50%) */ +#define SPI_CTL_FMODE 0x00040000/*Fast-mode Enable */ +#define SPI_CTL_MIOM 0x00300000/*Multiple I/O Mode */ +#define SPI_CTL_MIO_DIS 0x00000000/*MIOM: Disable */ +#define SPI_CTL_MIO_DUAL 0x00100000/*MIOM: Enable DIOM (Dual I/O Mode) */ +#define SPI_CTL_MIO_QUAD 0x00200000/*MIOM: Enable QUAD (Quad SPI Mode) */ +#define SPI_CTL_SOSI 0x00400000/*Start on MOSI */ +#define SPI_CTL_MMWEM 0x40000000/*Start on MMWEM */ +#define SPI_CTL_MMSE 0x80000000/*Start on MMSE */ +/* SPI_RX_CONTROL */ +#define SPI_RXCTL_REN 0x00000001/*Receive Channel Enable */ +#define SPI_RXCTL_RTI 0x00000004/*Receive Transfer Initiate */ +#define SPI_RXCTL_RWCEN 0x00000008/*Receive Word Counter Enable */ +#define SPI_RXCTL_RDR 0x00000070/*Receive Data Request */ +#define SPI_RXCTL_RDR_DIS 0x00000000/*RDR: Disabled */ +#define SPI_RXCTL_RDR_NE 0x00000010/*RDR: RFIFO not empty */ +#define SPI_RXCTL_RDR_25 0x00000020/*RDR: RFIFO 25% full */ +#define SPI_RXCTL_RDR_50 0x00000030/*RDR: RFIFO 50% full */ +#define SPI_RXCTL_RDR_75 0x00000040/*RDR: RFIFO 75% full */ +#define SPI_RXCTL_RDR_FULL 0x00000050/*RDR: RFIFO full */ +#define SPI_RXCTL_RDO 0x00000100/*Receive Data Over-Run */ +#define SPI_RXCTL_RRWM 0x00003000/*FIFO Regular Water-Mark */ +#define SPI_RXCTL_RWM_0 0x00000000/*RRWM: RFIFO Empty */ +#define SPI_RXCTL_RWM_25 0x00001000/*RRWM: RFIFO 25% full */ +#define SPI_RXCTL_RWM_50 0x00002000/*RRWM: RFIFO 50% full */ +#define SPI_RXCTL_RWM_75 0x00003000/*RRWM: RFIFO 75% full */ +#define SPI_RXCTL_RUWM 0x00070000/*FIFO Urgent Water-Mark */ +#define SPI_RXCTL_UWM_DIS 0x00000000/*RUWM: Disabled */ +#define SPI_RXCTL_UWM_25 0x00010000/*RUWM: RFIFO 25% full */ +#define SPI_RXCTL_UWM_50 0x00020000/*RUWM: RFIFO 50% full */ +#define SPI_RXCTL_UWM_75 0x00030000/*RUWM: RFIFO 75% full */ +#define SPI_RXCTL_UWM_FULL 0x00040000/*RUWM: RFIFO full */ +/* SPI_TX_CONTROL */ +#define SPI_TXCTL_TEN 0x00000001/*Transmit Channel Enable */ +#define SPI_TXCTL_TTI 0x00000004/*Transmit Transfer Initiate */ +#define SPI_TXCTL_TWCEN 0x00000008/*Transmit Word Counter Enable */ +#define SPI_TXCTL_TDR 0x00000070/*Transmit Data Request */ +#define SPI_TXCTL_TDR_DIS 0x00000000/*TDR: Disabled */ +#define SPI_TXCTL_TDR_NF 0x00000010/*TDR: TFIFO not full */ +#define SPI_TXCTL_TDR_25 0x00000020/*TDR: TFIFO 25% empty */ +#define SPI_TXCTL_TDR_50 0x00000030/*TDR: TFIFO 50% empty */ +#define SPI_TXCTL_TDR_75 0x00000040/*TDR: TFIFO 75% empty */ +#define SPI_TXCTL_TDR_EMPTY 0x00000050/*TDR: TFIFO empty */ +#define SPI_TXCTL_TDU 0x00000100/*Transmit Data Under-Run */ +#define SPI_TXCTL_TRWM 0x00003000/*FIFO Regular Water-Mark */ +#define SPI_TXCTL_RWM_FULL 0x00000000/*TRWM: TFIFO full */ +#define SPI_TXCTL_RWM_25 0x00001000/*TRWM: TFIFO 25% empty */ +#define SPI_TXCTL_RWM_50 0x00002000/*TRWM: TFIFO 50% empty */ +#define SPI_TXCTL_RWM_75 0x00003000/*TRWM: TFIFO 75% empty */ +#define SPI_TXCTL_TUWM 0x00070000/*FIFO Urgent Water-Mark */ +#define SPI_TXCTL_UWM_DIS 0x00000000/*TUWM: Disabled */ +#define SPI_TXCTL_UWM_25 0x00010000/*TUWM: TFIFO 25% empty */ +#define SPI_TXCTL_UWM_50 0x00020000/*TUWM: TFIFO 50% empty */ +#define SPI_TXCTL_UWM_75 0x00030000/*TUWM: TFIFO 75% empty */ +#define SPI_TXCTL_UWM_EMPTY 0x00040000/*TUWM: TFIFO empty */ +/* SPI_CLOCK */ +#define SPI_CLK_BAUD 0x0000FFFF/*Baud Rate */ +/* SPI_DELAY */ +#define SPI_DLY_STOP 0x000000FF/*Transfer delay time */ +#define SPI_DLY_LEADX 0x00000100/*Extended (1 SCK) LEAD Control */ +#define SPI_DLY_LAGX 0x00000200/*Extended (1 SCK) LAG control */ +/* SPI_SSEL */ +#define SPI_SLVSEL_SSE1 0x00000002/*SPISSEL1 Enable */ +#define SPI_SLVSEL_SSE2 0x00000004/*SPISSEL2 Enable */ +#define SPI_SLVSEL_SSE3 0x00000008/*SPISSEL3 Enable */ +#define SPI_SLVSEL_SSE4 0x00000010/*SPISSEL4 Enable */ +#define SPI_SLVSEL_SSE5 0x00000020/*SPISSEL5 Enable */ +#define SPI_SLVSEL_SSE6 0x00000040/*SPISSEL6 Enable */ +#define SPI_SLVSEL_SSE7 0x00000080/*SPISSEL7 Enable */ +#define SPI_SLVSEL_SSEL1 0x00000200/*SPISSEL1 Value */ +#define SPI_SLVSEL_SSEL2 0x00000400/*SPISSEL2 Value */ +#define SPI_SLVSEL_SSEL3 0x00000800/*SPISSEL3 Value */ +#define SPI_SLVSEL_SSEL4 0x00001000/*SPISSEL4 Value */ +#define SPI_SLVSEL_SSEL5 0x00002000/*SPISSEL5 Value */ +#define SPI_SLVSEL_SSEL6 0x00004000/*SPISSEL6 Value */ +#define SPI_SLVSEL_SSEL7 0x00008000/*SPISSEL7 Value */ +/* SPI_RWC */ +#define SPI_RWC_VALUE 0x0000FFFF/*Received Word-Count */ +/* SPI_RWCR */ +#define SPI_RWCR_VALUE 0x0000FFFF/*Received Word-Count Reload */ +/* SPI_TWC */ +#define SPI_TWC_VALUE 0x0000FFFF/*Transmitted Word-Count */ +/* SPI_TWCR */ +#define SPI_TWCR_VALUE 0x0000FFFF/*Transmitted Word-Count Reload */ +/* SPI_IMASK */ +#define SPI_IMSK_RUWM 0x00000002/*Receive Water-Mark Interrupt Mask */ +#define SPI_IMSK_TUWM 0x00000004/*Transmit Water-Mark Interrupt Mask */ +#define SPI_IMSK_ROM 0x00000010/*Receive Over-Run Interrupt Mask */ +#define SPI_IMSK_TUM 0x00000020/*Transmit Under-Run Interrupt Mask */ +#define SPI_IMSK_TCM 0x00000040/*Transmit Collision Interrupt Mask */ +#define SPI_IMSK_MFM 0x00000080/*Mode Fault Interrupt Mask */ +#define SPI_IMSK_RSM 0x00000100/*Receive Start Interrupt Mask */ +#define SPI_IMSK_TSM 0x00000200/*Transmit Start Interrupt Mask */ +#define SPI_IMSK_RFM 0x00000400/*Receive Finish Interrupt Mask */ +#define SPI_IMSK_TFM 0x00000800/*Transmit Finish Interrupt Mask */ +/* SPI_IMASKCL */ +#define SPI_IMSK_CLR_RUW 0x00000002/*Receive Water-Mark Interrupt Mask */ +#define SPI_IMSK_CLR_TUWM 0x00000004/*Transmit Water-Mark Interrupt Mask */ +#define SPI_IMSK_CLR_ROM 0x00000010/*Receive Over-Run Interrupt Mask */ +#define SPI_IMSK_CLR_TUM 0x00000020/*Transmit Under-Run Interrupt Mask */ +#define SPI_IMSK_CLR_TCM 0x00000040/*Transmit Collision Interrupt Mask */ +#define SPI_IMSK_CLR_MFM 0x00000080/*Mode Fault Interrupt Mask */ +#define SPI_IMSK_CLR_RSM 0x00000100/*Receive Start Interrupt Mask */ +#define SPI_IMSK_CLR_TSM 0x00000200/*Transmit Start Interrupt Mask */ +#define SPI_IMSK_CLR_RFM 0x00000400/*Receive Finish Interrupt Mask */ +#define SPI_IMSK_CLR_TFM 0x00000800/*Transmit Finish Interrupt Mask */ +/* SPI_IMASKST */ +#define SPI_IMSK_SET_RUWM 0x00000002/*Receive Water-Mark Interrupt Mask */ +#define SPI_IMSK_SET_TUWM 0x00000004/*Transmit Water-Mark Interrupt Mask */ +#define SPI_IMSK_SET_ROM 0x00000010/*Receive Over-Run Interrupt Mask */ +#define SPI_IMSK_SET_TUM 0x00000020/*Transmit Under-Run Interrupt Mask */ +#define SPI_IMSK_SET_TCM 0x00000040/*Transmit Collision Interrupt Mask */ +#define SPI_IMSK_SET_MFM 0x00000080/*Mode Fault Interrupt Mask */ +#define SPI_IMSK_SET_RSM 0x00000100/*Receive Start Interrupt Mask */ +#define SPI_IMSK_SET_TSM 0x00000200/*Transmit Start Interrupt Mask */ +#define SPI_IMSK_SET_RFM 0x00000400/*Receive Finish Interrupt Mask */ +#define SPI_IMSK_SET_TFM 0x00000800/*Transmit Finish Interrupt Mask */ +/* SPI_STATUS */ +#define SPI_STAT_SPIF 0x00000001/*SPI Finished */ +#define SPI_STAT_RUWM 0x00000002/*Receive Water-Mark Breached */ +#define SPI_STAT_TUWM 0x00000004/*Transmit Water-Mark Breached */ +#define SPI_STAT_ROE 0x00000010/*Receive Over-Run Indication */ +#define SPI_STAT_TUE 0x00000020/*Transmit Under-Run Indication */ +#define SPI_STAT_TCE 0x00000040/*Transmit Collision Indication */ +#define SPI_STAT_MODF 0x00000080/*Mode Fault Indication */ +#define SPI_STAT_RS 0x00000100/*Receive Start Indication */ +#define SPI_STAT_TS 0x00000200/*Transmit Start Indication */ +#define SPI_STAT_RF 0x00000400/*Receive Finish Indication */ +#define SPI_STAT_TF 0x00000800/*Transmit Finish Indication */ +#define SPI_STAT_RFS 0x00007000/*SPI_RFIFO status */ +#define SPI_STAT_RFIFO_EMPTY 0x00000000/*RFS: RFIFO Empty */ +#define SPI_STAT_RFIFO_25 0x00001000/*RFS: RFIFO 25% Full */ +#define SPI_STAT_RFIFO_50 0x00002000/*RFS: RFIFO 50% Full */ +#define SPI_STAT_RFIFO_75 0x00003000/*RFS: RFIFO 75% Full */ +#define SPI_STAT_RFIFO_FULL 0x00004000/*RFS: RFIFO Full */ +#define SPI_STAT_TFS 0x00070000/*SPI_TFIFO status */ +#define SPI_STAT_TFIFO_FULL 0x00000000/*TFS: TFIFO full */ +#define SPI_STAT_TFIFO_25 0x00010000/*TFS: TFIFO 25% empty */ +#define SPI_STAT_TFIFO_50 0x00020000/*TFS: TFIFO 50% empty */ +#define SPI_STAT_TFIFO_75 0x00030000/*TFS: TFIFO 75% empty */ +#define SPI_STAT_TFIFO_EMPTY 0x00040000/*TFS: TFIFO empty */ +#define SPI_STAT_FCS 0x00100000/*Flow-Control Stall Indication */ +#define SPI_STAT_RFE 0x00400000/*SPI_RFIFO Empty */ +#define SPI_STAT_TFF 0x00800000/*SPI_TFIFO Full */ +/* SPI_ILAT */ +#define SPI_ILAT_RUWMI 0x00000002/*Receive Water Mark Interrupt */ +#define SPI_ILAT_TUWMI 0x00000004/*Transmit Water Mark Interrupt */ +#define SPI_ILAT_ROI 0x00000010/*Receive Over-Run Indication */ +#define SPI_ILAT_TUI 0x00000020/*Transmit Under-Run Indication */ +#define SPI_ILAT_TCI 0x00000040/*Transmit Collision Indication */ +#define SPI_ILAT_MFI 0x00000080/*Mode Fault Indication */ +#define SPI_ILAT_RSI 0x00000100/*Receive Start Indication */ +#define SPI_ILAT_TSI 0x00000200/*Transmit Start Indication */ +#define SPI_ILAT_RFI 0x00000400/*Receive Finish Indication */ +#define SPI_ILAT_TFI 0x00000800/*Transmit Finish Indication */ +/* SPI_ILATCL */ +#define SPI_ILAT_CLR_RUWMI 0x00000002/*Receive Water Mark Interrupt */ +#define SPI_ILAT_CLR_TUWMI 0x00000004/*Transmit Water Mark Interrupt */ +#define SPI_ILAT_CLR_ROI 0x00000010/*Receive Over-Run Indication */ +#define SPI_ILAT_CLR_TUI 0x00000020/*Transmit Under-Run Indication */ +#define SPI_ILAT_CLR_TCI 0x00000040/*Transmit Collision Indication */ +#define SPI_ILAT_CLR_MFI 0x00000080/*Mode Fault Indication */ +#define SPI_ILAT_CLR_RSI 0x00000100/*Receive Start Indication */ +#define SPI_ILAT_CLR_TSI 0x00000200/*Transmit Start Indication */ +#define SPI_ILAT_CLR_RFI 0x00000400/*Receive Finish Indication */ +#define SPI_ILAT_CLR_TFI 0x00000800/*Transmit Finish Indication */ +/* SPI_MMRDH */ +#define SPI_MMRDH_MERGE 0x04000000/*Merge Enable */ +#define SPI_MMRDH_DMY_SZ 0x00007000/*Bytes of Dummy */ +#define SPI_MMRDH_ADDR_PINS 0x00000800/*Pins used for Address */ +#define SPI_MMRDH_ADDR_SZ 0x00000700/*Bytes of Read Address */ +#define SPI_MMRDH_OPCODE 0x000000FF/*Read Opcode */ + +#define SPI_MMRDH_TRIDMY_OFF 24/*Bytes of Dummy offset */ +#define SPI_MMRDH_DMY_SZ_OFF 12/*Bytes of Dummy offset */ +#define SPI_MMRDH_ADDR_SZ_OFF 8/*Bytes of Read Address offset */ + +#define BIT_SSEL_VAL (x) ((1 << 8) << (x))/* Slave Select input value bit */ +#define BIT_SSEL_EN (x) (1 << (x))/* Slave Select enable bit*/ + +struct adi_spi_regs { +u32 revid; +u32 control; +u32 rx_control; +u32 tx_control; +u32 clock; +u32 delay; +u32 ssel; +u32 rwc; +u32 rwcr; +u32 twc; +u32 twcr; +u32 reserved0; +u32 emask; +u32 emaskcl; +u32 emaskst; +u32 reserved1; +u32 status; +u32 elat; +u32 elatcl; +u32 reserved2; +u32 rfifo; +u32 reserved3;
drivers/spi/adi_spi3.c line 260
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+u32 tfifo; +u32 reserved4; +u32 mmrdh; +u32 mmtop; +}; + +struct adi_spi_platdata { +u32 max_hz; +u32 bus_num; +struct adi_spi_regs *regs;
This should be flagged __iomem
drivers/spi/adi_spi3.c line 268
Quoted 8 lines
drivers/spi/adi_spi3.c new file +8
-0+}; + +struct adi_spi_priv { +u32 control; +u32 clock; +u32 bus_num; +u32 max_cs; +struct adi_spi_regs *regs;
This should be flagged __iomem
drivers/spi/adi_spi3.c line 269
Quoted 1 line
drivers/spi/adi_spi3.c new file +1
-0+unsigned short *pins;
What is this used for ?
drivers/spi/adi_spi3.c line 270
Quoted 1 line
drivers/spi/adi_spi3.c new file +1
-0+void *memory_map;
What is this used for ?
drivers/spi/adi_spi3.c line 278
Quoted 8 lines
drivers/spi/adi_spi3.c new file +8
-0+}; + +static int adi_spi_cs_info (struct udevice *bus,uint cs, +struct spi_cs_info *info) +{ +struct adi_spi_priv *priv =dev_get_priv (bus); + +if (cs ==0 || cs > priv->max_cs) {
Isn't cs 0 a valid cs ?
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+dev_err (bus,"invalid chipselect %u\n" , cs); +return -EINVAL ; + } + +return 0 ; +} + +static int adi_spi_of_to_plat (struct udevice *bus) +{ +struct adi_spi_platdata *plat =dev_get_plat (bus);
drivers/spi/adi_spi3.c line 298
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+fdt_addr_t addr; + + plat->max_hz =dev_read_u32_default (bus,"spi-max-frequency" ,500000 ); + plat->bus_num =dev_read_u32_default (bus,"bus-num" ,0 ); + addr =dev_read_addr (bus); + +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + plat->regs = (struct adi_spi_regs *)addr;
__iomem missing.
map_sysmem() should be used in lieu of a simple cast.
Quoted 6 lines
drivers/spi/adi_spi3.c new file +6
-0+ +return 0 ; +} + +static int adi_spi_probe (struct udevice *bus) +{
drivers/spi/adi_spi3.c line 314
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+struct adi_spi_platdata *plat =dev_get_plat (bus); +struct adi_spi_priv *priv =dev_get_priv (bus); + + priv->bus_num = plat->bus_num; + priv->regs = plat->regs; + priv->max_cs =dev_read_u32_default (bus,"num-cs" ,MAX_CTRL_CS ); + +writel (0x0 , &plat->regs->control); +writel (0x0 , &plat->regs->rx_control); +writel (0x0 , &plat->regs->tx_control);
Would be better to used iowrite32() instead of writel() as it checks the __iomem pointer type.
Quoted 12 lines
drivers/spi/adi_spi3.c new file +12
-0+ +return 0 ; +} + +static int adi_spi_remove (struct udevice *dev) +{ +return -ENODEV ; +} + +static int adi_spi_claim_bus (struct udevice *dev) +{ +struct adi_spi_priv *priv;
drivers/spi/adi_spi3.c line 336
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+struct udevice *bus = dev->parent; + + priv =dev_get_priv (bus); + +debug ("%s: control:%i clock:%i\n" , + __func__, priv->control, priv->clock); + +writel (priv->control, &priv->regs->control); +writel (priv->clock, &priv->regs->clock); +writel (0x0 , &priv->regs->delay);
Same, use iowrite32()
Quoted 18 lines
drivers/spi/adi_spi3.c new file +18
-0+ +return 0 ; +} + +static int adi_spi_release_bus (struct udevice *dev) +{ +struct adi_spi_priv *priv; +struct udevice *bus = dev->parent; + + priv =dev_get_priv (bus); + +debug ("%s: control:%i clock:%i\n" , + __func__, priv->control, priv->clock); + +writel (0x0 , &priv->regs->rx_control); +writel (0x0 , &priv->regs->tx_control); +writel (0x0 , &priv->regs->control); +
drivers/spi/adi_spi3.c line 364
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+return 0 ; +} + +void adi_spi_enable_ssel (struct adi_spi_priv *priv,int cs) +{ +u32 ssel =readl (&priv->regs->ssel); + + ssel =readl (&priv->regs->ssel); + ssel |=BIT_SSEL_EN (cs); +writel (ssel, &priv->regs->ssel);
You have function setbits_32() to do that at once.
drivers/spi/adi_spi3.c line 375
Quoted 11 lines
drivers/spi/adi_spi3.c new file +11
-0+} + +void adi_spi_set_ssel (struct adi_spi_priv *priv,int cs,int high) +{ +u32 ssel =readl (&priv->regs->ssel); + +if (high) + ssel |=BIT_SSEL_VAL (cs); +else + ssel &= ~BIT_SSEL_VAL (cs); +writel (ssel, &priv->regs->ssel);
setbits_32() and clrbits_32() can be used.
drivers/spi/adi_spi3.c line 388
Quoted 13 lines
drivers/spi/adi_spi3.c new file +13
-0+} + +void adi_spi_cs_activate (struct adi_spi_priv *priv,struct dm_spi_slave_plat *slave_plat) +{ +bool high = slave_plat->mode &SPI_CS_HIGH ; + +adi_spi_set_ssel (priv, slave_plat->cs, high); +adi_spi_enable_ssel (priv, slave_plat->cs); +} + +void adi_spi_cs_deactivate (struct adi_spi_priv *priv,struct dm_spi_slave_plat *slave_plat) +{ +bool high = !(slave_plat->mode &SPI_CS_HIGH );
Confusing. 'high' is different from previous function. Would be clearer to call it 'low'.
Quoted 96 lines
drivers/spi/adi_spi3.c new file +96
-0+ +adi_spi_set_ssel (priv, slave_plat->cs, high); +} + +static void discard_rx_fifo_contents (struct adi_spi_regs *regs) +{ +while (!(readl (®s->status) &SPI_STAT_RFE )) +readl (®s->rfifo); +} + +static int adi_spi_fifo_mio_xfer (struct adi_spi_priv *priv,const u8 *tx,u8 *rx, +uint bytes,uint32_t mio_mode) +{ +u8 value; + +/* switch current SPI transfer to mio SPI mode */ +writel ((priv->control & ~SPI_CTL_SOSI ) | mio_mode, + &priv->regs->control); +/* +* Data can only be transferred in one direction in multi-io SPI +* modes, trigger the transfer in respective direction. +*/ +if (rx) { +writel (0x0 , &priv->regs->tx_control); +writel (SPI_RXCTL_REN |SPI_RXCTL_RTI , + &priv->regs->rx_control); + +while (bytes--) { +while (readl (&priv->regs->status) & +SPI_STAT_RFE ) +if (ctrlc ()) +return -1 ; + value =readl (&priv->regs->rfifo); + *rx++ = value; + } + }else if (tx) { +writel (0x0 , &priv->regs->rx_control); +writel (SPI_TXCTL_TEN |SPI_TXCTL_TTI , + &priv->regs->tx_control); + +while (bytes--) { + value = *tx++; +writel (value, &priv->regs->tfifo); +while (readl (&priv->regs->status) & +SPI_STAT_TFF ) +if (ctrlc ()) +return -1 ; + } + +/* Wait till the tfifo is empty */ +while ((readl (&priv->regs->status) &SPI_STAT_TFS ) != +0x40000 ) +if (ctrlc ()) +return -1 ; + }else { +return -1 ; + } +return 0 ; +} + +static int adi_spi_fifo_1x_xfer (struct adi_spi_priv *priv,const u8 *tx,u8 *rx, +uint bytes) +{ +u8 value; +int spi_idle; + +#if defined(CONFIG_SPI_IDLE_VAL ) + spi_idle =CONFIG_SPI_IDLE_VAL ; +#else + spi_idle =SPI_IDLE_VAL ; +#endif +/* +* Set current SPI transfer in normal mode and trigger +* the bi-direction transfer by tx write operation. +*/ +writel (priv->control, &priv->regs->control); +writel (SPI_RXCTL_REN , &priv->regs->rx_control); +writel (SPI_TXCTL_TEN |SPI_TXCTL_TTI , &priv->regs->tx_control); + +while (bytes--) { + value = (tx ? *tx++ : spi_idle); +debug ("%s: tx:%x " , __func__, value); +writel (value, &priv->regs->tfifo); +while (readl (&priv->regs->status) &SPI_STAT_RFE ) +if (ctrlc ()) +return -1 ; + value =readl (&priv->regs->rfifo); +if (rx) + *rx++ = value; +debug ("rx:%x\n" , value); + } +return 0 ; +} + +static int adi_spi_fifo_xfer (struct adi_spi_priv *priv,int buswidth, +const u8 *tx,u8 *rx,uint bytes)
drivers/spi/adi_spi3.c line 494
Quoted 10 lines
drivers/spi/adi_spi3.c new file +10
-0+{ +switch (buswidth) { +case 1 : +return adi_spi_fifo_1x_xfer (priv, tx, rx, bytes); +case 2 : +return adi_spi_fifo_mio_xfer (priv, tx, rx, bytes,SPI_CTL_MIO_DUAL ); +case 4 : +return adi_spi_fifo_mio_xfer (priv, tx, rx, bytes,SPI_CTL_MIO_QUAD ); +default : +return -ENOSYS ;
Wrong error code, this ones means /* Invalid system call number */
ENOTSUPP would be more correct.
Quoted 199 lines
drivers/spi/adi_spi3.c new file +196
-1+ } +} + +static int adi_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din,unsigned long flags) +{ +struct udevice *bus = dev->parent; +struct adi_spi_priv *priv =dev_get_priv (bus); +struct dm_spi_slave_plat *slave_plat =dev_get_parent_plat (dev); + +const u8 *tx = dout; +u8 *rx = din; +uint bytes = bitlen /8 ; +int ret =0 ; + +debug ("%s: bus_num:%i cs:%i bitlen:%i bytes:%i flags:%lx\n" , __func__, + priv->bus_num, slave_plat->cs, bitlen, bytes, flags); + +if (flags &SPI_XFER_BEGIN ) +adi_spi_cs_activate (priv, slave_plat); + +if (bitlen ==0 ) + goto done; + +/* we can only do 8 bit transfers */ +if (bitlen %8 ) { + flags |=SPI_XFER_END ; + goto done; + } + +/* Discard invalid rx data and empty rfifo */ +discard_rx_fifo_contents (priv->regs); + + ret =adi_spi_fifo_1x_xfer (priv, tx, rx, bytes); + + done: +if (flags &SPI_XFER_END ) +adi_spi_cs_deactivate (priv, slave_plat); + +return ret; +} + +static int adi_spi_set_speed (struct udevice *bus,uint speed) +{ +struct adi_spi_platdata *plat =dev_get_plat (bus); +struct adi_spi_priv *priv =dev_get_priv (bus); +int ret; +u32 clock, spi_base_clk; +struct clk spi_clk; + + ret =clk_get_by_name (bus,"spi" , &spi_clk); +if (ret <0 ) { +dev_err (bus,"Can't get SPI clk: %d\n" , ret); +return ret; + } + spi_base_clk =clk_get_rate (&spi_clk); + +if (speed > plat->max_hz) + speed = plat->max_hz; + +if (speed > spi_base_clk) +return -ENODEV ; + + clock = spi_base_clk / speed; +if (clock) + clock--; + + priv->clock = clock; + +debug ("%s: priv->clock: %x, speed: %x, get_spi_clk(): %x\n" , + __func__, clock, speed, spi_base_clk); + +return 0 ; +} + +static int adi_spi_set_mode (struct udevice *bus,uint mode) +{ +struct adi_spi_priv *priv =dev_get_priv (bus); +u32 reg; + + reg =SPI_CTL_EN |SPI_CTL_MSTR ; +if (mode &SPI_CPHA ) + reg |=SPI_CTL_CPHA ; +if (mode &SPI_CPOL ) + reg |=SPI_CTL_CPOL ; +if (mode &SPI_LSB_FIRST ) + reg |=SPI_CTL_LSBF ; + reg &= ~SPI_CTL_ASSEL ; + + priv->control = reg; + +debug ("%s: control=%d, cs_pol=%d\n" , __func__, reg, mode &SPI_CS_HIGH ?1 :0 ); + +return 0 ; +} + +/** +* U-boot's version of spi-mem does not support mixed bus-width +* commands nor anything more than 1x mode. +* Using a custom exec_op implementation, we can support it. +*/ +static int adi_spi_mem_exec_op (struct spi_slave *slave, +const struct spi_mem_op *op) +{ +int rv =0 ; +struct udevice *bus = slave->dev->parent; +struct adi_spi_priv *priv =dev_get_priv (bus); +struct dm_spi_slave_plat *slave_plat =dev_get_parent_plat (slave->dev); +u8 tmpbuf[64 ]; +int i; + +if ((op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes) > +sizeof (tmpbuf)) +return -ENOMEM ; + +for (i =0 ; i < op->cmd.nbytes; i++) + tmpbuf[i] = op->cmd.opcode >> + (8 * (op->cmd.nbytes - i -1 )); +for (i =0 ; i < op->addr.nbytes; i++) + tmpbuf[i + op->cmd.nbytes] = op->addr.val >> + (8 * (op->addr.nbytes - i -1 )); +memset (tmpbuf + op->addr.nbytes + op->cmd.nbytes,0xff , + op->dummy.nbytes); + +adi_spi_cs_activate (priv, slave_plat); +discard_rx_fifo_contents (priv->regs); + +if (op->cmd.nbytes) { + rv =adi_spi_fifo_xfer (priv, op->cmd.buswidth, + tmpbuf,NULL , op->cmd.nbytes); +if (rv !=0 ) + goto cleanup; + } + +if (op->addr.nbytes) { + rv =adi_spi_fifo_xfer (priv, op->addr.buswidth, + tmpbuf + op->cmd.nbytes,NULL , + op->addr.nbytes); +if (rv !=0 ) + goto cleanup; + } + +if (op->dummy.nbytes) { + rv =adi_spi_fifo_xfer (priv, op->dummy.buswidth, + tmpbuf + op->cmd.nbytes + + op->addr.nbytes, +NULL , op->dummy.nbytes); +if (rv !=0 ) + goto cleanup; + } + +if (op->data.dir ==SPI_MEM_DATA_IN ) + rv =adi_spi_fifo_xfer (priv, op->data.buswidth, +NULL , op->data.buf.in, + op->data.nbytes); +else if (op->data.dir ==SPI_MEM_DATA_OUT ) + rv =adi_spi_fifo_xfer (priv, op->data.buswidth, + op->data.buf.out,NULL , + op->data.nbytes); + +cleanup: +adi_spi_cs_deactivate (priv, slave_plat); +return rv; +} + +static const struct spi_controller_mem_ops adi_spi_mem_ops = { + .exec_op = adi_spi_mem_exec_op, +}; + +static const struct dm_spi_ops adi_spi_ops = { + .claim_bus = adi_spi_claim_bus, + .release_bus = adi_spi_release_bus, + .xfer = adi_spi_xfer, + .set_speed = adi_spi_set_speed, + .set_mode = adi_spi_set_mode, + .cs_info = adi_spi_cs_info, + .mem_ops = &adi_spi_mem_ops, +}; + +static const struct udevice_id adi_spi_ids[] = { + { .compatible ="adi,spi3" }, + { } +}; + +U_BOOT_DRIVER (adi_spi3) = { + .name ="adi_spi3" , + .id =UCLASS_SPI , + .of_match = adi_spi_ids, + .ops = &adi_spi_ops, + .of_to_plat = adi_spi_of_to_plat, + .probe = adi_spi_probe, + .remove = adi_spi_remove, + .plat_auto =sizeof (struct adi_spi_platdata ), + .priv_auto =sizeof (struct adi_spi_priv ), + .per_child_auto =sizeof (struct spi_slave ), +}; --2.43.2
PATCH 11/11 mmc: Add support for ADI SC5XX-family processor SDHCI peripherals
In reply to Greg MalysaFrom: Nathan Barrett-Morrison <[email protected]>
---
MAINTAINERS | 1 + drivers/mmc/Kconfig | 8 +++ drivers/mmc/Makefile | 1 + drivers/mmc/adi_sdhci.c | 152 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+) create mode 100644 drivers/mmc/adi_sdhci.c
MAINTAINERS +1 -0
@@ -614,6 +614,7 @@ F: drivers/dma/adi_dma.c F: drivers/gpio/adp5588_gpio.c F: drivers/gpio/gpio-adi-adsp.c F: drivers/i2c/adi_i2c.c +F: drivers/mmc/adi_sdhci.c F: drivers/net/dwc_eth_qos_adi.c F: drivers/pinctrl/pinctrl-adi-adsp.c F: drivers/remoteproc/adi_sc5xx_rproc.c
drivers/mmc/Kconfig +8 -0
@@ -283,6 +283,14 @@ config MMC_DW_ROCKCHIP SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well as removeable SD and micro-SD cards. +config MMC_SDHCI_ADI + bool "ADI SD/MMC controller support" + depends on DM_MMC && OF_CONTROL + depends on MMC_SDHCI && MMC_SDHCI_ADMA + help + This enables support for the SD/MMC controller included in some Analog + Devices SC5XX Socs. + config MMC_DW_SOCFPGA bool "SOCFPGA specific extensions for Synopsys DW Memory Card Interface" depends on ARCH_SOCFPGA
drivers/mmc/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_MMC_SDHCI_MV) += mv_sdhci.o obj-$(CONFIG_MMC_SDHCI_NPCM) += npcm_sdhci.o obj-$(CONFIG_MMC_SDHCI_PIC32) += pic32_sdhci.o obj-$(CONFIG_MMC_SDHCI_ROCKCHIP) += rockchip_sdhci.o +obj-$(CONFIG_MMC_SDHCI_ADI) += adi_sdhci.o obj-$(CONFIG_MMC_SDHCI_S5P) += s5p_sdhci.o obj-$(CONFIG_MMC_SDHCI_STI) += sti_sdhci.o obj-$(CONFIG_MMC_SDHCI_TANGIER) += tangier_sdhci.o
drivers/mmc/adi_sdhci.c new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
2.43.2