OMAP: Move SATA to use block driver model
Subsystems (6)
v2 cover OMAP: Move SATA to use block driver model
This series adds support for SATA using the driver model on omap platforms. It is based on the work of Mugunthan V N <[email protected]> in Feb 2016
The first 2 patches are preparatory work.
The 3rd patch adds a new framework to handle PHYs in a generic manner. The idea is to move the phy initialization out of the board-specific code into a proper driver. The link between the phy device and the controller device is done in by device-tree as it's done in linux. The API to control a phy has been copied from linux, excpet that the functions are prefixed by 'generic_phy_' instead of just 'phy_' because phy_reset() is already used to handle the Ethernet phys. The 4th patch adds a phy driver for the pipe3 sata phy found in the omaps/am5x/dra7x SOCs.
The 5th patch allows the device under the node ocp2scp at 4a090000 to be probed. The 6th patch implements a driver for the SATA controller found in the omaps/am5x/dra7x SOCs.
The 7th patch is cosmetic and changes the interface of scsi_detect_dev() The 8th patch moves the call to part_init() out of scsi_detect_dev(). This is a preparatory work path #9.
The 9th patches fix a divide-by-0 error that happens in scsi_scan() when DM is used.
The last patch enables the DM sata by default for the dra7 platforms.
changes since v1:
* changed the way the 'old' sata code is compiled out when DM_SCSI is enabled.
* added a new framework for PHY management.
* added a new driver for the PIPE3 phy and use it in the dwc_ahci driver.
* changed the interface of scsi_detect_dev() and moved the call part_init() out of it.
* modified the fix to scsi_scan() in order to call scsi_detect_dev() only once.
* the max_lun and max_id parameters are now taken from the device-tree.
* Updated the defconfig changes to include the PHY driver and its dependencies.
Jean-Jacques Hiblot (8):
arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI
is defined
drivers: phy: add generic PHY framework
drivers: phy: add PIPE3 phy driver
dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
scsi: make the LUN a parameter of scsi_detect_dev()
scsi: move the partition initialization out of the scsi detection
dm: scsi: fix divide-by-0 error in scsi_scan()
defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for
SCSI
Mugunthan V N (2):
arm: omap: sata: move enable sata clocks to enable_basic_clocks()
drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata
device
Makefile | 1 + arch/arm/dts/dra7.dtsi | 2 +- arch/arm/mach-omap2/Makefile | 2 + arch/arm/mach-omap2/omap5/hw_data.c | 12 ++ arch/arm/mach-omap2/sata.c | 23 --- common/scsi.c | 48 +++-- configs/dra7xx_evm_defconfig | 12 +- configs/dra7xx_hs_evm_defconfig | 11 +- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/block/Kconfig | 10 + drivers/block/Makefile | 1 + drivers/block/dwc_ahci.c | 100 ++++++++++ drivers/phy/Kconfig | 34 ++++ drivers/phy/Makefile | 6 + drivers/phy/phy-uclass.c | 77 ++++++++ drivers/phy/ti-pipe3-phy.c | 368 ++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++ 19 files changed, 708 insertions(+), 41 deletions(-) create mode 100644 drivers/block/dwc_ahci.c create mode 100644 drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create mode 100644 drivers/phy/phy-uclass.c create mode 100644 drivers/phy/ti-pipe3-phy.c create mode 100644 include/generic-phy.h
Signature · 1 line
1.9.1
PATCH v2 1/10 arm: omap: sata: move enable sata clocks to enable_basic_clocks()
From: Mugunthan V N <[email protected]>
All the clocks which has to be enabled has to be done in enable_basic_clocks(), so moving enable sata clock to common clocks enable function.
---
the patch hasn't changed since v1
arch/arm/mach-omap2/omap5/hw_data.c | 12 ++++++++++++
arch/arm/mach-omap2/sata.c | 23 ----------------------- 2 files changed, 12 insertions(+), 23 deletions(-)
arch/arm/mach-omap2/omap5/hw_data.c +12 -0
@@ -361,6 +361,9 @@ void enable_basic_clocks(void) (*prcm)->cm_l4per_gpio6_clkctrl, (*prcm)->cm_l4per_gpio7_clkctrl, (*prcm)->cm_l4per_gpio8_clkctrl, +#ifdef CONFIG_SCSI_AHCI_PLAT + (*prcm)->cm_l3init_ocp2scp3_clkctrl, +#endif 0 };
@@ -379,6 +382,9 @@ void enable_basic_clocks(void)#ifdef CONFIG_TI_QSPI (*prcm)->cm_l4per_qspi_clkctrl,#endif +#ifdef CONFIG_SCSI_AHCI_PLAT + (*prcm)->cm_l3init_sata_clkctrl, +#endif0 };
@@ -411,6 +417,12 @@ void enable_basic_clocks(void)setbits_le32 ((*prcm)->cm_l4per_qspi_clkctrl, (1 <<24 ));#endif +#ifdef CONFIG_SCSI_AHCI_PLAT +/* Enable optional functional clock for SATA */ +setbits_le32 ((*prcm)->cm_l3init_sata_clkctrl, +SATA_CLKCTRL_OPTFCLKEN_MASK ); +#endif +/* Enable SCRM OPT clocks for PER and CORE dpll */ setbits_le32 ((*prcm)->cm_wkupaon_scrm_clkctrl,OPTFCLKEN_SCRM_PER_MASK );
arch/arm/mach-omap2/sata.c +0 -23
@@ -37,29 +37,6 @@ int init_sata(int dev)int ret;u32 val; -u32 const clk_domains_sata[] = { -0 - }; - -u32 const clk_modules_hw_auto_sata[] = { - (*prcm)->cm_l3init_ocp2scp3_clkctrl, -0 - }; - -u32 const clk_modules_explicit_en_sata[] = { - (*prcm)->cm_l3init_sata_clkctrl, -0 - }; - -do_enable_clocks (clk_domains_sata, - clk_modules_hw_auto_sata, - clk_modules_explicit_en_sata, -0 ); - -/* Enable optional functional clock for SATA */ -setbits_le32 ((*prcm)->cm_l3init_sata_clkctrl, -SATA_CLKCTRL_OPTFCLKEN_MASK ); - sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata;/* Power up the PHY */
Signature · 1 line
1.9.1
PATCH v2 1/10 arm: omap: sata: move enable sata clocks to enable_basic_clocks()
Quoted 9 lines · Jean-Jacques Hiblot
From: Mugunthan V N <[email protected]>
All the clocks which has to be enabled has to be done in
enable_basic_clocks(), so moving enable sata clock to common clocks enable function.Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Jean-Jacques Hiblot <[email protected]>Reviewed-by Tom Rini <[email protected]>
Quoted 7 lines
---
the patch hasn't changed since v1
arch/arm/mach-omap2/omap5/hw_data.c| 12 ++++++++++++arch/arm/mach-omap2/sata.c | 23 ----------------------- 2 files changed, 12 insertions(+), 23 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 2/10 arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined
In reply to Jean-Jacques HiblotWhen CONFIG_DM_SCSI is defined, the SATA initialization will be implemented in the scsi-uclass driver.
---
Instead of compiling out the code inside the C file, let's just not compile the files at all.
arch/arm/mach-omap2/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-omap2/Makefile +2 -0
@@ -29,9 +29,11 @@ obj-y += abb.o endif ifneq ($(CONFIG_OMAP54XX),) +ifeq ($(CONFIG_DM_SCSI),) obj-y += pipe3-phy.o obj-$(CONFIG_SCSI_AHCI_PLAT) += sata.o endif +endif ifeq ($(CONFIG_SYS_DCACHE_OFF),) obj-y += omap-cache.o
Signature · 1 line
1.9.1
PATCH v2 2/10 arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined
Quoted 4 lines · Jean-Jacques Hiblot
When
CONFIG_DM_SCSIis defined, the SATA initialization will be implemented in the scsi-uclass driver.Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/7f648da8/attachment.sig>
PATCH v2 2/10 arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined
Quoted 11 lines · Tom Rini
Quoted 4 lines · Jean-Jacques Hiblot
When
CONFIG_DM_SCSIis defined, the SATA initialization will be implemented in the scsi-uclass driver.Signed-off-by Jean-Jacques Hiblot <[email protected]>Reviewed-by Tom Rini <[email protected]>--
Tom
Applied to u-boot-dm, thanks!
PATCH v2 3/10 drivers: phy: add generic PHY framework
In reply to Jean-Jacques HiblotThe PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports init(), deinit(), power_on, power_off() and reset(). The framework provides a way to get a reference to a phy from the device-tree.
--- Makefile | 1 + drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/phy/Kconfig | 22 ++++++++++++++ drivers/phy/Makefile | 5 ++++ drivers/phy/phy-uclass.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++++++++++++++++++++++ 8 files changed, 147 insertions(+) create mode 100644 drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create mode 100644 drivers/phy/phy-uclass.c create mode 100644 include/generic-phy.h
Makefile +1 -0
@@ -650,6 +650,7 @@ libs-y += fs/ libs-y += net/ libs-y += disk/ libs-y += drivers/ +libs-y += drivers/phy/ libs-y += drivers/dma/ libs-y += drivers/gpio/ libs-y += drivers/i2c/
drivers/Kconfig +2 -0
@@ -88,6 +88,8 @@ source "drivers/video/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/phy/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" help
drivers/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_SPL_GENERIC_PHY) += phy/ endif ifdef CONFIG_TPL_BUILD
drivers/phy/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ + +menu "PHY Subsystem" + +config GENERIC_PHY + bool "PHY Core" + depends on DM + help + Generic PHY support. + + This framework is designed to provide a generic interface for PHY + devices. + +config SPL_GENERIC_PHY + bool "PHY Core in SPL" + depends on DM + help + Generic PHY support in SPL. + + This framework is designed to provide a generic interface for PHY + devices. + +endmenu
drivers/phy/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o + +ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) +obj-y += marvell/ +endif
drivers/phy/phy-uclass.c new file +77 -0
77 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_VIDEO ,/* Video or LCD device */ UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ +UCLASS_PHY ,/* generic PHY device */ UCLASS_COUNT , UCLASS_INVALID = -1,
include/generic-phy.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ +* Written by Jean-Jacques Hiblot <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __GENERIC_PHY_H +#define __GENERIC_PHY_H + +struct generic_phy ; +/* +* struct generic_phy_ops - set of function pointers for phy operations +* @init: operation to be performed for initializing phy +* @exit: operation to be performed while exiting +* @power_on: powering on the phy +* @power_off: powering off the phy +*/ +struct generic_phy_ops { +int (*init)(struct udevice *phy); +int (*exit)(struct udevice *phy); +int (*reset)(struct udevice *phy); +int (*power_on)(struct udevice *phy); +int (*power_off)(struct udevice *phy); +}; + + +int generic_phy_init (struct generic_phy *phy); +int generic_phy_reset (struct generic_phy *phy); +int generic_phy_exit (struct generic_phy *phy); +int generic_phy_power_on (struct generic_phy *phy); +int generic_phy_power_off (struct generic_phy *phy); + +struct generic_phy *dm_generic_phy_get (struct udevice *dev,const char *string); + +#endif /*__GENERIC_PHY_H */
Signature · 1 line
1.9.1
PATCH v2 3/10 drivers: phy: add generic PHY framework
Quoted 7 lines · Jean-Jacques Hiblot
The PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports
init(),deinit(),power_on,power_off()andreset(). The framework provides a way to get a reference to a phy from the device-tree.Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/fac48bde/attachment.sig>
PATCH v2 3/10 drivers: phy: add generic PHY framework
In reply to Jean-Jacques HiblotHi,
Quoted 7 lines · Jean-Jacques Hiblot
The PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports
init(),deinit(),power_on,power_off()andreset(). The framework provides a way to get a reference to a phy from the device-tree.Signed-off-by Jean-Jacques Hiblot <[email protected]>
Quoted 14 lines
--- Makefile | 1 + drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/phy/Kconfig | 22 ++++++++++++++ drivers/phy/Makefile | 5 ++++ drivers/phy/phy-uclass.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++++++++++++++++++++++ 8 files changed, 147 insertions(+) create mode 100644 drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create mode 100644 drivers/phy/phy-uclass.c create mode 100644 include/generic-phy.h
Can you please create a sandbox driver and a test?
Makefile libs-y += fs/ · line 653
Quoted 10 lines
Makefile +1
-0@@ -650,6 +650,7 @@ libs-y += fs/ libs-y += net/ libs-y += disk/ libs-y += drivers/ +libs-y += drivers/phy/
Could this go in drivers/Makefile?
Quoted 34 lines
Makefile +0
-0libs-y += drivers/dma/ libs-y += drivers/gpio/ libs-y += drivers/i2c/drivers/Kconfig +2
-0@@ -88,6 +88,8 @@ source "drivers/video/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/phy/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" helpdrivers/Makefile +1
-0@@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_SPL_GENERIC_PHY) += phy/ endif ifdef CONFIG_TPL_BUILDdrivers/phy/Kconfig new file +0
-0
drivers/phy/Kconfig line 4
Quoted 4 lines
drivers/phy/Kconfig new file +4
-0@@ -0,0 +1,22 @@ + +menu "PHY Subsystem" + +config GENERIC_PHY
Just a question: do you think we need the word GENERIC in this config? I'm OK with it, but wonder if CONFIG_PHY would be enough?
drivers/phy/Kconfig line 11
Quoted 7 lines
drivers/phy/Kconfig new file +7
-0+ bool "PHY Core" + depends on DM + help + Generic PHY support. + + This framework is designed to provide a generic interface for PHY + devices.
Could you given a few examples of PHY devices and the types of operations you can perform on them.
Quoted 28 lines
drivers/phy/Kconfig new file +11
-0+ +config SPL_GENERIC_PHY + bool "PHY Core in SPL" + depends on DM + help + Generic PHY support in SPL. + + This framework is designed to provide a generic interface for PHY + devices. + +endmenudrivers/phy/Makefile new file +5
-0@@ -0,0 +1,5 @@ +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o + +ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) +obj-y += marvell/ +endifdrivers/phy/phy-uclass.c new file +0
-0
drivers/phy/phy-uclass.c line 7
Quoted 7 lines
drivers/phy/phy-uclass.c new file +7
-0@@ -0,0 +1,77 @@ +/* +* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ +* Written by Jean-Jacques Hiblot <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation.
SPDX?
Quoted 4 lines
drivers/phy/phy-uclass.c new file +4
-0+*/ + +#include <common.h> +#include <dm.h>
drivers/phy/phy-uclass.c line 21
Quoted 10 lines
drivers/phy/phy-uclass.c new file +10
-0+#include <generic-phy.h> + +#define get_ops (dev) ((struct generic_phy_ops *)(dev)->driver->ops) + +#define generic_phy_to_dev (x) ((struct udevice *)(x)) +#define dev_to_generic_phy (x) ((struct generic_phy *)(x)) + +struct generic_phy *dm_generic_phy_get (struct udevice *dev,const char *string) +{ +struct udevice *generic_phy_dev;
dev is a shorter name :-)
Quoted 40 lines
drivers/phy/phy-uclass.c new file +40
-0+ +int rc =uclass_get_device_by_phandle (UCLASS_PHY , dev, + string, &generic_phy_dev); +if (rc) { +error ("unable to find generic_phy device %d\n" , rc); +return ERR_PTR (rc); + } +return dev_to_generic_phy (generic_phy_dev); +} + +int generic_phy_init (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->init) ? ops->init (dev) :0 ; +} + +int generic_phy_reset (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->reset) ? ops->reset (dev) :0 ; +} + +int generic_phy_exit (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->exit) ? ops->exit (dev) :0 ; +} + +int generic_phy_power_on (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->power_on) ? ops->power_on (dev) :0 ;
drivers/phy/phy-uclass.c line 71
Quoted 10 lines
drivers/phy/phy-uclass.c new file +10
-0+} + +int generic_phy_power_off (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->power_off) ? ops->power_off (dev) :0 ; +} +
Drop 2 extra blank ilnes
drivers/phy/phy-uclass.c line 74
Quoted 3 lines
drivers/phy/phy-uclass.c new file +3
-0+ + +UCLASS_DRIVER (simple_generic_phy) = {
remove the word 'simple' ?
Quoted 30 lines
drivers/phy/phy-uclass.c new file +3
-0+ .id = UCLASS_PHY, + .name = "generic_phy", +};include/dm/uclass-id.h +1
-0@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_VIDEO ,/* Video or LCD device */ UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ +UCLASS_PHY ,/* generic PHY device */ UCLASS_COUNT , UCLASS_INVALID = -1,include/generic-phy.h new file +9
-0@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ +* Written by Jean-Jacques Hiblot <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +
include/generic-phy.h line 19
Quoted 10 lines
include/generic-phy.h new file +10
-0+#ifndef __GENERIC_PHY_H +#define __GENERIC_PHY_H + +struct generic_phy ; +/* +* struct generic_phy_ops - set of function pointers for phy operations +* @init: operation to be performed for initializing phy +* @exit: operation to be performed while exiting +* @power_on: powering on the phy +* @power_off: powering off the phy
Need to mention that these are all optional (from what I can tell above).
include/generic-phy.h line 30
Quoted 11 lines
include/generic-phy.h new file +11
-0+*/ +struct generic_phy_ops { +int (*init)(struct udevice *phy); +int (*exit)(struct udevice *phy); +int (*reset)(struct udevice *phy); +int (*power_on)(struct udevice *phy); +int (*power_off)(struct udevice *phy); +}; + + +int generic_phy_init (struct generic_phy *phy);
Why do these not use struct udevice?
Quoted 11 lines
include/generic-phy.h new file +8
-1+int generic_phy_reset (struct generic_phy *phy); +int generic_phy_exit (struct generic_phy *phy); +int generic_phy_power_on (struct generic_phy *phy); +int generic_phy_power_off (struct generic_phy *phy); + +struct generic_phy *dm_generic_phy_get (struct udevice *dev,const char *string); + +#endif /*__GENERIC_PHY_H */ --1.9.1
Regards,
Simon
PATCH v2 3/10 drivers: phy: add generic PHY framework
Quoted 24 lines · Simon Glass
Hi,
Quoted 17 lines · Jean-Jacques Hiblot
The PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports
init(),deinit(),power_on,power_off()andreset(). The framework provides a way to get a reference to a phy from the device-tree.Signed-off-by Jean-Jacques Hiblot <[email protected]>--- Makefile | 1 + drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/phy/Kconfig | 22 ++++++++++++++ drivers/phy/Makefile | 5 ++++ drivers/phy/phy-uclass.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++++++++++++++++++++++ 8 files changed, 147 insertions(+)Quoted 4 lines
create mode 100644
drivers/phy/Kconfig
create mode 100644drivers/phy/Makefile
create mode 100644drivers/phy/phy-uclass.c
create mode 100644include/generic-phy.h
Quoted 1 line
Can you please create a sandbox driver and a test?
Sure. I'll add something. It'll be pretty basic though
Quoted 11 lines
Makefile libs-y += fs/ · line 653
Quoted 10 lines
Makefile +1
-0@@ -650,6 +650,7 @@ libs-y += fs/ libs-y += net/ libs-y += disk/ libs-y += drivers/ +libs-y += drivers/phy/Could this go in
drivers/Makefile?
OK
Quoted 28 lines
Quoted 28 lines
Makefile +0
-0libs-y += drivers/dma/ libs-y += drivers/gpio/ libs-y += drivers/i2c/drivers/Kconfig +2
-0@@ -88,6 +88,8 @@ source "drivers/video/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/phy/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" helpdrivers/Makefile +1
-0@@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_SPL_GENERIC_PHY) += phy/ endif
Quoted 13 lines
drivers/phy/Kconfig line 4
Quoted 11 lines
drivers/Makefile +0
-0ifdef CONFIG_TPL_BUILDdrivers/phy/Kconfig new file +4
-0@@ -0,0 +1,22 @@ + +menu "PHY Subsystem" + +config GENERIC_PHYJust a question: do you think we need the word GENERIC in this config? I'm OK with it, but wonder if
CONFIG_PHYwould be enough?
GENERIC_PHY is the name of the config option in the kernel and the functions are also prefixed with generic_phy_.
BTW the functions in linux are not prefixed with generic_phy_ but only phy_, but in the case of u-boot a lot of phy_xxx() functions already exist and are not necessarily static (like phy_reset() for ther ethernet phy).
Quoted 10 lines
drivers/phy/Kconfig line 11
Quoted 8 lines
drivers/phy/Kconfig new file +7
-0+ bool "PHY Core" + depends on DM + help + Generic PHY support. + + This framework is designed to provide a generic interface for PHY + devices.Could you given a few examples of PHY devices and the types of operations you can perform on them.
OK
Quoted 29 lines
Quoted 29 lines
drivers/phy/Kconfig new file +11
-0+ +config SPL_GENERIC_PHY + bool "PHY Core in SPL" + depends on DM + help + Generic PHY support in SPL. + + This framework is designed to provide a generic interface for PHY + devices. + +endmenudrivers/phy/Makefile new file +5
-0@@ -0,0 +1,5 @@ +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o + +ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) +obj-y += marvell/ +endifdrivers/phy/phy-uclass.c new file +0
-0@@ -0,0 +1,77 @@
Quoted 8 lines
drivers/phy/phy-uclass.c line 7
Quoted 7 lines
drivers/phy/phy-uclass.c new file +7
-0+/* +* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ +* Written by Jean-Jacques Hiblot <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. SPDX?
OK
Quoted 16 lines
Quoted 5 lines
drivers/phy/phy-uclass.c new file +4
-0+*/ + +#include <common.h> +#include <dm.h> drivers/phy/phy-uclass.c line 21
Quoted 10 lines
drivers/phy/phy-uclass.c new file +10
-0+#include <generic-phy.h> + +#define get_ops (dev) ((struct generic_phy_ops *)(dev)->driver->ops) + +#define generic_phy_to_dev (x) ((struct udevice *)(x)) +#define dev_to_generic_phy (x) ((struct generic_phy *)(x)) + +struct generic_phy *dm_generic_phy_get (struct udevice *dev,const char *string) +{ +struct udevice *generic_phy_dev;dev is a shorter name :-)
indeed
Quoted 53 lines
Quoted 41 lines
drivers/phy/phy-uclass.c new file +40
-0+ +int rc =uclass_get_device_by_phandle (UCLASS_PHY , dev, + string, &generic_phy_dev); +if (rc) { +error ("unable to find generic_phy device %d\n" , rc); +return ERR_PTR (rc); + } +return dev_to_generic_phy (generic_phy_dev); +} + +int generic_phy_init (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->init) ? ops->init (dev) :0 ; +} + +int generic_phy_reset (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->reset) ? ops->reset (dev) :0 ; +} + +int generic_phy_exit (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->exit) ? ops->exit (dev) :0 ; +} + +int generic_phy_power_on (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->power_on) ? ops->power_on (dev) :0 ;drivers/phy/phy-uclass.c line 71
Quoted 10 lines
drivers/phy/phy-uclass.c new file +10
-0+} + +int generic_phy_power_off (struct generic_phy *generic_phy) +{ +struct udevice *dev =generic_phy_to_dev (generic_phy); +struct generic_phy_ops *ops =get_ops (dev); + +return (ops && ops->power_off) ? ops->power_off (dev) :0 ; +} +Drop 2 extra blank ilnes
Quoted 4 lines
drivers/phy/phy-uclass.c line 74
Quoted 3 lines
drivers/phy/phy-uclass.c new file +3
-0+ + +UCLASS_DRIVER (simple_generic_phy) = {remove the word 'simple' ?
OK
Quoted 34 lines
Quoted 34 lines
drivers/phy/phy-uclass.c new file +3
-0+ .id = UCLASS_PHY, + .name = "generic_phy", +};include/dm/uclass-id.h +1
-0@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_VIDEO ,/* Video or LCD device */ UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ +UCLASS_PHY ,/* generic PHY device */ UCLASS_COUNT , UCLASS_INVALID = -1,include/generic-phy.h new file +12
-0@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ +* Written by Jean-Jacques Hiblot <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __GENERIC_PHY_H +#define __GENERIC_PHY_H +
Quoted 8 lines
include/generic-phy.h line 19
Quoted 7 lines
include/generic-phy.h new file +7
-0+struct generic_phy ; +/* +* struct generic_phy_ops - set of function pointers for phy operations +* @init: operation to be performed for initializing phy +* @exit: operation to be performed while exiting +* @power_on: powering on the phy +* @power_off: powering off the phy Need to mention that these are all optional (from what I can tell above).
OK
Quoted 13 lines
include/generic-phy.h line 30
Quoted 12 lines
include/generic-phy.h new file +11
-0+*/ +struct generic_phy_ops { +int (*init)(struct udevice *phy); +int (*exit)(struct udevice *phy); +int (*reset)(struct udevice *phy); +int (*power_on)(struct udevice *phy); +int (*power_off)(struct udevice *phy); +}; + + +int generic_phy_init (struct generic_phy *phy);Why do these not use struct udevice?
It's quite easy for the PHY driver to get its internal data structure from the struct udevice*.
I could also have passed struct generic_phy * but it adds another translation that I don't think is necessary.
Quoted 15 lines
Quoted 10 lines
include/generic-phy.h new file +8
-1+int generic_phy_reset (struct generic_phy *phy); +int generic_phy_exit (struct generic_phy *phy); +int generic_phy_power_on (struct generic_phy *phy); +int generic_phy_power_off (struct generic_phy *phy); + +struct generic_phy *dm_generic_phy_get (struct udevice *dev,const char *string); + +#endif /*__GENERIC_PHY_H */ --Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 3/10 drivers: phy: add generic PHY framework
Hi Jean-Jacques,
Quoted 32 lines · Jean-Jacques Hiblot
Quoted 29 lines · Simon Glass
Hi,
Quoted 24 lines · Jean-Jacques Hiblot
The PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports
init(),deinit(),power_on,power_off()andreset(). The framework provides a way to get a reference to a phy from the
device-tree.Signed-off-by Jean-Jacques Hiblot <[email protected]>--- Makefile | 1 + drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/phy/Kconfig | 22 ++++++++++++++ drivers/phy/Makefile | 5 ++++ drivers/phy/phy-uclass.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++++++++++++++++++++++ 8 files changed, 147 insertions(+)create mode 100644
drivers/phy/Kconfig
create mode 100644drivers/phy/Makefile
create mode 100644drivers/phy/phy-uclass.c
create mode 100644include/generic-phy.h
Quoted 3 lines
Quoted 1 line
Can you please create a sandbox driver and a test?
Sure. I'll add something. It'll be pretty basic though
Basic is fine. It needs to create a device or two and call some methods.
Quoted 59 lines
Quoted 13 lines
Makefile libs-y += fs/ · line 653
Quoted 11 lines
Makefile +1
-0@@ -650,6 +650,7 @@ libs-y += fs/ libs-y += net/ libs-y += disk/ libs-y += drivers/ +libs-y += drivers/phy/Could this go in
drivers/Makefile?OK
Quoted 28 lines
Quoted 28 lines
Makefile +0
-0libs-y += drivers/dma/ libs-y += drivers/gpio/ libs-y += drivers/i2c/drivers/Kconfig +2
-0@@ -88,6 +88,8 @@ source "drivers/video/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/phy/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" helpdrivers/Makefile +1
-0@@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_SPL_GENERIC_PHY) += phy/ endifQuoted 14 lines
drivers/phy/Kconfig line 4
Quoted 11 lines
drivers/Makefile +0
-0ifdef CONFIG_TPL_BUILDdrivers/phy/Kconfig new file +4
-0@@ -0,0 +1,22 @@ + +menu "PHY Subsystem" + +config GENERIC_PHYJust a question: do you think we need the word GENERIC in this config? I'm OK with it, but wonder if
CONFIG_PHYwould be enough?
Quoted 5 lines
GENERIC_PHYis the name of the config option in the kernel and the functions are also prefixed withgeneric_phy_.
BTW the functions in linux are not prefixed withgeneric_phy_but onlyphy_, but in the case of u-boot a lot ofphy_xxx()functions already exist and are not necessarily static (likephy_reset()for ther ethernet phy).
OK.
[..]
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/phy/Kconfig new file +5
-0+ */ +struct generic_phy_ops { + int (*init)(struct udevice *phy); + int (*exit)(struct udevice *phy); + int (*reset)(struct udevice *phy);Quoted 8 lines
drivers/phy/Kconfig line 15
Quoted 6 lines
drivers/phy/Kconfig new file +6
-0+ int (*power_on)(struct udevice *phy); + int (*power_off)(struct udevice *phy); +}; + + +int generic_phy_init(struct generic_phy *phy);Why do these not use struct udevice?
Quoted 4 lines
It's quite easy for the PHY driver to get its internal data structure from the struct udevice*.
I could also have passed structgeneric_phy* but it adds another translation that I don't think is necessary.
I'd like to change that for consistency. A uclass API is supposed to take a struct udevice * rather than anything else. It is confusing if one uclass does this differently. The translation is cheap and some users will have a struct udevice * readily available.
Quoted 19 lines
Quoted 18 lines
Quoted 13 lines
drivers/phy/Kconfig new file +6
-0+int generic_phy_reset(struct generic_phy *phy); +int generic_phy_exit(struct generic_phy *phy); +int generic_phy_power_on(struct generic_phy *phy); +int generic_phy_power_off(struct generic_phy *phy); + +struct generic_phy *dm_generic_phy_get(struct udevice *dev, const char*string);
drivers/phy/Kconfig new file +2
-1+ +#endif /*__GENERIC_PHY_H */ --Quoted 2 lines
1.9.1
Regards,
Simon
Regards,
Simon
PATCH v2 3/10 drivers: phy: add generic PHY framework
Quoted 108 lines · Simon Glass
Hi Jean-Jacques,
Quoted 28 lines · Jean-Jacques Hiblot
Quoted 26 lines · Simon Glass
Hi,
Quoted 23 lines · Jean-Jacques Hiblot
The PHY framework provides a set of APIs to control a PHY. This API is derived from the linux version of the generic PHY framework. Currently the API supports
init(),deinit(),power_on,power_off()andreset(). The framework provides a way to get a reference to a phy from the
device-tree.Signed-off-by Jean-Jacques Hiblot <[email protected]>--- Makefile | 1 + drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/phy/Kconfig | 22 ++++++++++++++ drivers/phy/Makefile | 5 ++++ drivers/phy/phy-uclass.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/generic-phy.h | 38 ++++++++++++++++++++++++ 8 files changed, 147 insertions(+)create mode 100644
drivers/phy/Kconfig
create mode 100644drivers/phy/Makefile
create mode 100644drivers/phy/phy-uclass.c
create mode 100644include/generic-phy.hQuoted 2 lines
Quoted 1 line
Can you please create a sandbox driver and a test?
Sure. I'll add something. It'll be pretty basic though
Basic is fine. It needs to create a device or two and call some methods.
Quoted 53 lines
Quoted 11 lines
Makefile libs-y += fs/ · line 653
Quoted 10 lines
Makefile +1
-0@@ -650,6 +650,7 @@ libs-y += fs/ libs-y += net/ libs-y += disk/ libs-y += drivers/ +libs-y += drivers/phy/Could this go in
drivers/Makefile?OK
Quoted 27 lines
Quoted 27 lines
Makefile +0
-0libs-y += drivers/dma/ libs-y += drivers/gpio/ libs-y += drivers/i2c/drivers/Kconfig +2
-0@@ -88,6 +88,8 @@ source "drivers/video/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/phy/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" helpdrivers/Makefile +1
-0@@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_SPL_GENERIC_PHY) += phy/ endifQuoted 13 lines
drivers/phy/Kconfig line 4
Quoted 11 lines
drivers/Makefile +0
-0ifdef CONFIG_TPL_BUILDdrivers/phy/Kconfig new file +4
-0@@ -0,0 +1,22 @@ + +menu "PHY Subsystem" + +config GENERIC_PHYJust a question: do you think we need the word GENERIC in this config? I'm OK with it, but wonder if
CONFIG_PHYwould be enough?Quoted 5 lines
GENERIC_PHYis the name of the config option in the kernel and the functions are also prefixed withgeneric_phy_.
BTW the functions in linux are not prefixed withgeneric_phy_but onlyphy_, but in the case of u-boot a lot ofphy_xxx()functions already exist and are not necessarily static (likephy_reset()for ther ethernet phy).OK.
[..]Quoted 12 lines
Quoted 12 lines
drivers/phy/Kconfig line 15
Quoted 11 lines
drivers/phy/Kconfig new file +11
-0+ */ +struct generic_phy_ops { + int (*init)(struct udevice *phy); + int (*exit)(struct udevice *phy); + int (*reset)(struct udevice *phy); + int (*power_on)(struct udevice *phy); + int (*power_off)(struct udevice *phy); +}; + + +int generic_phy_init(struct generic_phy *phy);Why do these not use struct udevice?
Quoted 8 lines
Quoted 4 lines
It's quite easy for the PHY driver to get its internal data structure from the struct udevice*.
I could also have passed structgeneric_phy* but it adds another translation that I don't think is necessary.I'd like to change that for consistency. A uclass API is supposed to take a struct udevice * rather than anything else. It is confusing if one uclass does this differently. The translation is cheap and some users will have a struct udevice * readily available..
Yes I eventually figured this out while working on the unit tests v3. This has been changed.
Jean-Jacques
Quoted 20 lines
Quoted 17 lines
Quoted 17 lines
Quoted 12 lines
drivers/phy/Kconfig new file +6
-0+int generic_phy_reset(struct generic_phy *phy); +int generic_phy_exit(struct generic_phy *phy); +int generic_phy_power_on(struct generic_phy *phy); +int generic_phy_power_off(struct generic_phy *phy); + +struct generic_phy *dm_generic_phy_get(struct udevice *dev, const char*string);
drivers/phy/Kconfig new file +2
-1+ +#endif /*__GENERIC_PHY_H */ --Quoted 2 lines
1.9.1
Regards,
SimonRegards,
Simon
PATCH v2 4/10 drivers: phy: add PIPE3 phy driver
In reply to Jean-Jacques HiblotThis phy is found on omap platforms with sata capabilities. Except for the part related to the DM and the PHY framework, the code is basically a copy paste from arch/arm/mach-omap2/pipe3-phy.c
--- drivers/phy/Kconfig | 12 ++ drivers/phy/Makefile | 1 + drivers/phy/ti-pipe3-phy.c | 368 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/phy/ti-pipe3-phy.c
drivers/phy/Kconfig +12 -0
@@ -19,4 +19,16 @@ config SPL_GENERIC_PHY This framework is designed to provide a generic interface for PHY devices. +config PIPE3_PHY + bool "Support omap's PIPE3 PHY" + depends on GENERIC_PHY + help + Support for the omap PIPE3 phy for sata + +config SPL_PIPE3_PHY + bool "Support omap's PIPE3 PHY in SPL" + depends on SPL_GENERIC_PHY + help + Support for the omap PIPE3 phy for sata in SPL + endmenu
drivers/phy/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o +obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) obj-y += marvell/
drivers/phy/ti-pipe3-phy.c new file +368 -0
368 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 4/10 drivers: phy: add PIPE3 phy driver
Quoted 5 lines · Jean-Jacques Hiblot
This phy is found on omap platforms with sata capabilities. Except for the part related to the DM and the PHY framework, the code is basically a copy paste from
arch/arm/mach-omap2/pipe3-phy.cSigned-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/6f3f03ac/attachment.sig>
PATCH v2 4/10 drivers: phy: add PIPE3 phy driver
In reply to Jean-Jacques HiblotQuoted 4 lines · Jean-Jacques Hiblot
This phy is found on omap platforms with sata capabilities. Except for the part related to the DM and the PHY framework, the code is basically a copy paste from
arch/arm/mach-omap2/pipe3-phy.c
Quoted 8 lines
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- drivers/phy/Kconfig | 12 ++ drivers/phy/Makefile | 1 + drivers/phy/ti-pipe3-phy.c | 368 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/phy/ti-pipe3-phy.c
PATCH v2 5/10 dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
In reply to Jean-Jacques HiblotThis is needed to probe devices under that bus such as the SATA PHY.
--- arch/arm/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/dra7.dtsi +1 -1
@@ -1317,7 +1317,7 @@ /* OCP2SCP3 */ ocp2scp at 4a090000 { - compatible = "ti,omap-ocp2scp"; + compatible = "ti,omap-ocp2scp", "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges;
Signature · 1 line
1.9.1
PATCH v2 5/10 dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
Quoted 12 lines · Jean-Jacques Hiblot
This is needed to probe devices under that bus such as the SATA PHY.
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- arch/arm/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/dts/dra7.dtsi +0
-0
arch/arm/dts/dra7.dtsi line 1323
Quoted 8 lines
arch/arm/dts/dra7.dtsi +1
-1@@ -1317,7 +1317,7 @@ /* OCP2SCP3 */ ocp2scp at 4a090000 { - compatible = "ti,omap-ocp2scp"; + compatible = "ti,omap-ocp2scp", "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges;
This is U-Boot specific I assume? It should end up in a -u-boot.dtsi file instead so we don't overwrite it later.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/d5f45455/attachment.sig>
PATCH v2 5/10 dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
Quoted 15 lines · Tom Rini
Quoted 13 lines · Jean-Jacques Hiblot
This is needed to probe devices under that bus such as the SATA PHY.
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- arch/arm/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/dts/dra7.dtsi +0
-0@@ -1317,7 +1317,7 @@
Quoted 9 lines
arch/arm/dts/dra7.dtsi line 1323
Quoted 7 lines
arch/arm/dts/dra7.dtsi +1
-1/* OCP2SCP3 */ ocp2scp at 4a090000 { - compatible = "ti,omap-ocp2scp"; + compatible = "ti,omap-ocp2scp", "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges;This is U-Boot specific I assume? It should end up in a
-u-boot.dtsifile instead so we don't overwrite it later.
OK. I'll put it in omap5-u-boot.dtsi
Quoted 1 line
PATCH v2 6/10 drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
In reply to Jean-Jacques HiblotFrom: Mugunthan V N <[email protected]>
Implement a sata driver for Synopsys DWC sata device based on U-boot driver model.
--- drivers/block/Kconfig | 10 +++++ drivers/block/Makefile | 1 + drivers/block/dwc_ahci.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 drivers/block/dwc_ahci.c
drivers/block/Kconfig +10 -0
@@ -48,4 +48,14 @@ config SATA_CEVA ZynqMP. Support up to 2 external devices. Complient with SATA 3.1 and AHCI 1.3 specifications with hot-plug detect feature. + +config DWC_AHCI + bool "Enable Synopsys DWC AHCI driver support" + select SCSI_AHCI + select GENERIC_PHY + depends on DM_SCSI + help + Enable this driver to support Sata devices through + Synopsys DWC AHCI module. + endmenu
drivers/block/Makefile +1 -0
@@ -11,6 +11,7 @@ ifndef CONFIG_BLK obj-y += blk_legacy.o endif +obj-$(CONFIG_DWC_AHCI) += dwc_ahci.o obj-$(CONFIG_AHCI) += ahci-uclass.o obj-$(CONFIG_DM_SCSI) += scsi-uclass.o obj-$(CONFIG_SCSI_AHCI) += ahci.o
drivers/block/dwc_ahci.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/10 drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
Quoted 7 lines · Jean-Jacques Hiblot
From: Mugunthan V N <[email protected]>
Implement a sata driver for Synopsys DWC sata device based on U-boot driver model.
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/a899f810/attachment.sig>
PATCH v2 6/10 drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
In reply to Jean-Jacques HiblotQuoted 5 lines · Jean-Jacques Hiblot
From: Mugunthan V N <[email protected]>
Implement a sata driver for Synopsys DWC sata device based on U-boot driver model.
Quoted 8 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Jean-Jacques Hiblot <[email protected]>--- drivers/block/Kconfig | 10 +++++ drivers/block/Makefile | 1 + drivers/block/dwc_ahci.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 drivers/block/dwc_ahci.c
PATCH v2 7/10 scsi: make the LUN a parameter of scsi_detect_dev()
In reply to Jean-Jacques HiblotThis is a cosmetic change. target and LUN have kind of the same role in this function. One of them was passed as a parameter and the other was embedded in a structure. For consistency, pass both of them as parameters.
--- common/scsi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
common/scsi.c +7 -7
@@ -473,14 +473,15 @@ static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)* scsi_detect_dev - Detect scsi device * * @target: target id +* @lun: target lun * @dev_desc: block device description * * The scsi_detect_dev detects and fills a dev_desc structure when the device is -* detected. The LUN number is taken from the struct blk_desc *dev_desc. +* detected. * * Return: 0 on success, error value otherwise */ -static int scsi_detect_dev (int target,struct blk_desc *dev_desc) +static int scsi_detect_dev (int target,int lun,struct blk_desc *dev_desc) {unsigned char perq, modi;lbaint_t capacity;
@@ -488,7 +489,7 @@ static int scsi_detect_dev(int target, struct blk_desc *dev_desc)ccb *pccb = (ccb *)&tempccb; pccb->target = target; - pccb->lun = dev_desc->lun; + pccb->lun = lun; pccb->pdata = (unsigned char *)&tempbuff; pccb->datalen =512 ;scsi_setup_inquiry (pccb);
@@ -599,8 +600,7 @@ int scsi_scan(int mode) bdesc =dev_get_uclass_platdata (bdev);scsi_init_dev_desc_priv (bdesc); - bdesc->lun = lun; - ret =scsi_detect_dev (i, bdesc); + ret =scsi_detect_dev (i, lun, bdesc);if (ret) {device_unbind (bdev);continue ;
@@ -630,8 +630,8 @@ int scsi_scan(int mode) scsi_max_devs =0 ;for (i =0 ; i <CONFIG_SYS_SCSI_MAX_SCSI_ID ; i++) {for (lun =0 ; lun <CONFIG_SYS_SCSI_MAX_LUN ; lun++) { - scsi_dev_desc[scsi_max_devs].lun = lun; - ret =scsi_detect_dev (i, &scsi_dev_desc[scsi_max_devs]); + ret =scsi_detect_dev (i, lun, + &scsi_dev_desc[scsi_max_devs]);if (ret)continue ;
Signature · 1 line
1.9.1
PATCH v2 7/10 scsi: make the LUN a parameter of scsi_detect_dev()
Quoted 5 lines · Jean-Jacques Hiblot
This is a cosmetic change. target and LUN have kind of the same role in this function. One of them was passed as a parameter and the other was embedded in a structure. For consistency, pass both of them as parameters.
Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/6a2b1fd6/attachment.sig>
PATCH v2 7/10 scsi: make the LUN a parameter of scsi_detect_dev()
In reply to Jean-Jacques HiblotQuoted 9 lines · Jean-Jacques Hiblot
This is a cosmetic change. target and LUN have kind of the same role in this function. One of them was passed as a parameter and the other was embedded in a structure. For consistency, pass both of them as parameters.
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
PATCH v2 7/10 scsi: make the LUN a parameter of scsi_detect_dev()
Quoted 5 lines · Simon Glass
Quoted 4 lines · Jean-Jacques Hiblot
This is a cosmetic change. target and LUN have kind of the same role in this function. One of them was passed as a parameter and the other was embedded in a structure. For consistency, pass both of them as parameters.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)Reviewed-by Simon Glass <[email protected]>
Applied to u-boot-dm, thanks!
PATCH v2 8/10 scsi: move the partition initialization out of the scsi detection
In reply to Jean-Jacques HiblotWe might want to get information about the scsi device without initializing the partition.
--- common/scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
common/scsi.c +2 -1
@@ -540,7 +540,6 @@ static int scsi_detect_dev(int target, int lun, struct blk_desc *dev_desc) dev_desc->blksz = blksz; dev_desc->log2blksz =LOG2 (dev_desc->blksz); dev_desc->type = perq; -part_init (&dev_desc[0 ]); removable:return 0 ; }
@@ -605,6 +604,7 @@ int scsi_scan(int mode)device_unbind (bdev);continue ; } +part_init (bdesc);if (mode ==1 ) {printf (" Device %d: " ,0 );
@@ -634,6 +634,7 @@ int scsi_scan(int mode) &scsi_dev_desc[scsi_max_devs]);if (ret)continue ; +part_init (&scsi_dev_desc[scsi_max_devs]);if (mode ==1 ) {printf (" Device %d: " ,0 );
Signature · 1 line
1.9.1
PATCH v2 8/10 scsi: move the partition initialization out of the scsi detection
Quoted 3 lines · Jean-Jacques Hiblot
We might want to get information about the scsi device without initializing the partition.
Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/c38cab28/attachment.sig>
PATCH v2 8/10 scsi: move the partition initialization out of the scsi detection
In reply to Jean-Jacques HiblotQuoted 6 lines · Jean-Jacques Hiblot
We might want to get information about the scsi device without initializing the partition.
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH v2 8/10 scsi: move the partition initialization out of the scsi detection
Quoted 9 lines · Simon Glass
Quoted 6 lines · Jean-Jacques Hiblot
We might want to get information about the scsi device without initializing the partition.
Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Simon Glass <[email protected]>
Applied to u-boot-dm, thanks!
PATCH v2 9/10 dm: scsi: fix divide-by-0 error in scsi_scan()
In reply to Jean-Jacques HiblotWith DM_SCSI enabled, blk_create_devicef() is called with blkz = 0, leading to a divide-by-0 exception.scsi_detect_dev() can be used to get the required parameters (block size and number of blocks) from the drive before calling blk_create_devicef().
--- common/scsi.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
common/scsi.c +26 -9
@@ -580,9 +580,19 @@ int scsi_scan(int mode)for (lun =0 ; lun < plat->max_lun; lun++) {struct udevice *bdev;/* block device */ /* block device description */ +struct blk_desc _bd;struct blk_desc *bdesc;char str[10 ]; +scsi_init_dev_desc_priv (&_bd); + ret =scsi_detect_dev (i, lun, &_bd); +if (ret) +/* +* no device detected? +* check the next lun. +*/ +continue ; +/* * Create only one block device and do detection * to make sure that there won't be a lot of
@@ -590,20 +600,27 @@ int scsi_scan(int mode)*/ snprintf (str,sizeof (str),"id%dlun%d" , i, lun); ret =blk_create_devicef (dev,"scsi_blk" , - str,IF_TYPE_SCSI , --1 ,0 ,0 , &bdev); + str,IF_TYPE_SCSI , +-1 , + _bd.blksz, + _bd.blksz * _bd.lba, + &bdev);if (ret) {debug ("Can't create device\n" );return ret; } - bdesc =dev_get_uclass_platdata (bdev); -scsi_init_dev_desc_priv (bdesc); - ret =scsi_detect_dev (i, lun, bdesc); -if (ret) { -device_unbind (bdev); -continue ; - } + bdesc =dev_get_uclass_platdata (bdev); + bdesc->target = i; + bdesc->lun = lun; + bdesc->removable = _bd.removable; + bdesc->type = _bd.type; +memcpy (&bdesc->vendor, &_bd.vendor, +sizeof (_bd.vendor)); +memcpy (&bdesc->product, &_bd.product, +sizeof (_bd.product)); +memcpy (&bdesc->revision, &_bd.revision, +sizeof (_bd.revision));part_init (bdesc);if (mode ==1 ) {
Signature · 1 line
1.9.1
PATCH v2 9/10 dm: scsi: fix divide-by-0 error in scsi_scan()
Quoted 6 lines · Jean-Jacques Hiblot
With
DM_SCSIenabled,blk_create_devicef()is called with blkz = 0, leading to a divide-by-0 exception.scsi_detect_dev()can be used to get the required parameters (block size and number of blocks) from the drive before callingblk_create_devicef().Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/948634dd/attachment.sig>
PATCH v2 9/10 dm: scsi: fix divide-by-0 error in scsi_scan()
In reply to Jean-Jacques HiblotHi,
Quoted 9 lines · Jean-Jacques Hiblot
With
DM_SCSIenabled,blk_create_devicef()is called with blkz = 0, leading to a divide-by-0 exception.scsi_detect_dev()can be used to get the required parameters (block size and number of blocks) from the drive before callingblk_create_devicef().Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
Please see below.
Quoted 49 lines
common/scsi.c +16
-9@@ -580,9 +580,19 @@ int scsi_scan(int mode)for (lun =0 ; lun < plat->max_lun; lun++) {struct udevice *bdev;/* block device */ /* block device description */ +struct blk_desc _bd;struct blk_desc *bdesc;char str[10 ]; +scsi_init_dev_desc_priv (&_bd); + ret =scsi_detect_dev (i, lun, &_bd); +if (ret) +/* +* no device detected? +* check the next lun. +*/ +continue ; +/* * Create only one block device and do detection * to make sure that there won't be a lot of @@ -590,20 +600,27 @@ int scsi_scan(int mode)*/ snprintf (str,sizeof (str),"id%dlun%d" , i, lun); ret =blk_create_devicef (dev,"scsi_blk" , - str,IF_TYPE_SCSI , --1 ,0 ,0 , &bdev); + str,IF_TYPE_SCSI , +-1 , + _bd.blksz, + _bd.blksz * _bd.lba, + &bdev);if (ret) {debug ("Can't create device\n" );return ret; } - bdesc =dev_get_uclass_platdata (bdev); -scsi_init_dev_desc_priv (bdesc); - ret =scsi_detect_dev (i, lun, bdesc); -if (ret) { -device_unbind (bdev); -continue ; - } + bdesc =dev_get_uclass_platdata (bdev);
common/scsi.c int scsi_scan(int mode) · line 623
Quoted 10 lines
common/scsi.c +10
-0+ bdesc->target = i; + bdesc->lun = lun; + bdesc->removable = _bd.removable; + bdesc->type = _bd.type; +memcpy (&bdesc->vendor, &_bd.vendor, +sizeof (_bd.vendor)); +memcpy (&bdesc->product, &_bd.product, +sizeof (_bd.product)); +memcpy (&bdesc->revision, &_bd.revision, +sizeof (_bd.revision));
Can you please move this block (inside the double for loops) into a separate function? It is getting too long. A follow-up patch is fine since you have already done this.
Quoted 6 lines
common/scsi.c +0
-1part_init (bdesc);if (mode ==1 ) { --1.9.1
Regards,
Simon
PATCH v2 9/10 dm: scsi: fix divide-by-0 error in scsi_scan()
Quoted 83 lines · Simon Glass
Hi,
Quoted 9 lines · Jean-Jacques Hiblot
With
DM_SCSIenabled,blk_create_devicef()is called with blkz = 0, leading to a divide-by-0 exception.scsi_detect_dev()can be used to get the required parameters (block size and number of blocks) from the drive before callingblk_create_devicef().Signed-off-by Jean-Jacques Hiblot <[email protected]>--- common/scsi.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)Reviewed-by Simon Glass <[email protected]>Please see below.
Quoted 49 lines
common/scsi.c +16
-9@@ -580,9 +580,19 @@ int scsi_scan(int mode)for (lun =0 ; lun < plat->max_lun; lun++) {struct udevice *bdev;/* block device */ /* block device description */ +struct blk_desc _bd;struct blk_desc *bdesc;char str[10 ]; +scsi_init_dev_desc_priv (&_bd); + ret =scsi_detect_dev (i, lun, &_bd); +if (ret) +/* +* no device detected? +* check the next lun. +*/ +continue ; +/* * Create only one block device and do detection * to make sure that there won't be a lot of @@ -590,20 +600,27 @@ int scsi_scan(int mode)*/ snprintf (str,sizeof (str),"id%dlun%d" , i, lun); ret =blk_create_devicef (dev,"scsi_blk" , - str,IF_TYPE_SCSI , --1 ,0 ,0 , &bdev); + str,IF_TYPE_SCSI , +-1 , + _bd.blksz, + _bd.blksz * _bd.lba, + &bdev);if (ret) {debug ("Can't create device\n" );return ret; } - bdesc =dev_get_uclass_platdata (bdev); -scsi_init_dev_desc_priv (bdesc); - ret =scsi_detect_dev (i, lun, bdesc); -if (ret) { -device_unbind (bdev); -continue ; - } + bdesc =dev_get_uclass_platdata (bdev);common/scsi.c int scsi_scan(int mode) · line 623
Quoted 10 lines
common/scsi.c +10
-0+ bdesc->target = i; + bdesc->lun = lun; + bdesc->removable = _bd.removable; + bdesc->type = _bd.type; +memcpy (&bdesc->vendor, &_bd.vendor, +sizeof (_bd.vendor)); +memcpy (&bdesc->product, &_bd.product, +sizeof (_bd.product)); +memcpy (&bdesc->revision, &_bd.revision, +sizeof (_bd.revision));Can you please move this block (inside the double for loops) into a separate function? It is getting too long. A follow-up patch is fine since you have already done this.
Quoted 2 lines
common/scsi.c +0
-0part_init (bdesc);
Quoted 7 lines
Quoted 4 lines
common/scsi.c +0
-1if (mode ==1 ) { --1.9.1
Regards,
Simon
Applied to u-boot-dm, thanks!
PATCH v2 10/10 defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI
In reply to Jean-Jacques HiblotEnable disk driver model for dra7xx_evm as dwc_ahci supports driver model. As a consequence we must also enable CONFIG_BLK and CONFIG_DM_USB.
--- configs/dra7xx_evm_defconfig | 12 +++++++++++- configs/dra7xx_hs_evm_defconfig | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-)
configs/dra7xx_evm_defconfig +11 -1
@@ -59,7 +59,13 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y CONFIG_SPL_DM=y -# CONFIG_BLK is not set +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_BLK=y +CONFIG_DM_SCSI=y +CONFIG_DWC_AHCI=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y
@@ -89,6 +95,7 @@ CONFIG_TI_QSPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y
@@ -101,3 +108,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0451 CONFIG_G_DNL_PRODUCT_NUM=0xd022 +CONFIG_SPL_GENERIC_PHY=y +CONFIG_PIPE3_PHY=y +CONFIG_SPL_PIPE3_PHY=y
configs/dra7xx_hs_evm_defconfig +10 -1
@@ -63,7 +63,12 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y CONFIG_SPL_DM=y -# CONFIG_BLK is not set +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_DM_SCSI=y +CONFIG_DWC_AHCI=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y
@@ -93,6 +98,7 @@ CONFIG_TI_QSPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y
@@ -105,3 +111,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0451 CONFIG_G_DNL_PRODUCT_NUM=0xd022 +CONFIG_SPL_GENERIC_PHY=y +CONFIG_PIPE3_PHY=y +CONFIG_SPL_PIPE3_PHY=y
Signature · 1 line
1.9.1
PATCH v2 10/10 defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI
Quoted 6 lines · Jean-Jacques Hiblot
Enable disk driver model for
dra7xx_evmasdwc_ahcisupports driver model. As a consequence we must also enableCONFIG_BLKandCONFIG_DM_USB.Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Jean-Jacques Hiblot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170408/4abc0f20/attachment.sig>