2018-01-20 03:22:16

by David Lechner

[permalink] [raw]
Subject: [PATCH 0/6] ARM: davinci: common clock prep work

This series contains some changes needed for the conversion of arch/arm/mach-
davinci to the common clock framework.

Most of the boards in mach-davinci do not have device tree support. However,
CFGCHIP, which is a syscon regmap, is needed during clock init in early boot.
Using a platform device for the syscon at this point is not an option. So,
this series introduces a new way to register a syscon regmap on non-DT systems.

The DA8XX USB PHY driver is a consumer of the CFGCHIP syscon regmap, so some
changes are needed in that driver as well since we are removing the syscon
platform devices. The patch "phy: da8xx-usb: rename clock con_ids" doesn't
have anything to do with syscon, but I included in this series because we are
touching PHY code here anyway and it is also a dependency for the upcoming
common clock framework conversion changes.

Maintainers, please coordinate with Sekhar before committing. We will probably
want everything to go through the linux-davinci tree if possible.

David Lechner (6):
mfd: syscon: Add syscon_register() function
phy: da8xx-usb: Always check for syscon compatible
phy: da8xx-usb: rename clock con_ids
ARM: davinci: move davinci_clk_init() to init_time
ARM: da8xx: Move CFGCHIP registration to init_time
phy: da8xx-usb: drop use of syscon_regmap_lookup_by_pdevname()

arch/arm/mach-davinci/board-da830-evm.c | 6 +--
arch/arm/mach-davinci/board-da850-evm.c | 6 +--
arch/arm/mach-davinci/board-dm355-evm.c | 2 +-
arch/arm/mach-davinci/board-dm355-leopard.c | 2 +-
arch/arm/mach-davinci/board-dm365-evm.c | 2 +-
arch/arm/mach-davinci/board-dm644x-evm.c | 2 +-
arch/arm/mach-davinci/board-dm646x-evm.c | 19 +++++---
arch/arm/mach-davinci/board-mityomapl138.c | 6 +--
arch/arm/mach-davinci/board-neuros-osd2.c | 2 +-
arch/arm/mach-davinci/board-omapl138-hawk.c | 6 +--
arch/arm/mach-davinci/board-sffsdr.c | 2 +-
arch/arm/mach-davinci/da830.c | 8 +++-
arch/arm/mach-davinci/da850.c | 31 ++++++-------
arch/arm/mach-davinci/da8xx-dt.c | 2 +-
arch/arm/mach-davinci/davinci.h | 4 ++
arch/arm/mach-davinci/devices-da8xx.c | 29 ++----------
arch/arm/mach-davinci/dm355.c | 8 +++-
arch/arm/mach-davinci/dm365.c | 8 +++-
arch/arm/mach-davinci/dm644x.c | 8 +++-
arch/arm/mach-davinci/dm646x.c | 22 ++++-----
arch/arm/mach-davinci/include/mach/common.h | 1 -
arch/arm/mach-davinci/include/mach/da8xx.h | 6 ++-
arch/arm/mach-davinci/usb-da8xx.c | 12 ++---
drivers/mfd/syscon.c | 71 +++++++++++++++++++++++++++++
drivers/phy/ti/phy-da8xx-usb.c | 14 ++----
include/linux/mfd/syscon.h | 9 ++++
26 files changed, 178 insertions(+), 110 deletions(-)

--
2.7.4



2018-01-20 03:22:27

by David Lechner

[permalink] [raw]
Subject: [PATCH 1/6] mfd: syscon: Add syscon_register() function

This adds a new syscon_register() function that creates a new syscon
regmap and adds it to the lookup list.

This function serves two purposes:

1. This is needed for platforms without device tree support where the
syscon regmap is needed in early boot (e.g. clocks), because using a
platform driver at this point in boot is not an option.

2. It allows other drivers to use syscon_regmap_lookup_by_compatible()
for both device tree and non-DT platforms instead of having to have
a separate case that calls syscon_regmap_lookup_by_pdevname().

Signed-off-by: David Lechner <[email protected]>
---
drivers/mfd/syscon.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mfd/syscon.h | 9 ++++++
2 files changed, 80 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index b93fe4c..ab086b1 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -25,6 +25,8 @@
#include <linux/mfd/syscon.h>
#include <linux/slab.h>

+#define SYSCON_COMPATIBLE_SIZE 50
+
static struct platform_driver syscon_driver;

static DEFINE_SPINLOCK(syscon_list_slock);
@@ -34,6 +36,7 @@ struct syscon {
struct device_node *np;
struct regmap *regmap;
struct list_head list;
+ char compatible[SYSCON_COMPATIBLE_SIZE];
};

static const struct regmap_config syscon_regmap_config = {
@@ -140,9 +143,27 @@ EXPORT_SYMBOL_GPL(syscon_node_to_regmap);

struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
{
+ struct syscon *entry, *syscon = NULL;
struct device_node *syscon_np;
struct regmap *regmap;

+ spin_lock(&syscon_list_slock);
+
+ /* Check for entries registered with syscon_register() */
+ list_for_each_entry(entry, &syscon_list, list) {
+ if (!entry->compatible)
+ continue;
+ if (!strncmp(entry->compatible, s, SYSCON_COMPATIBLE_SIZE)) {
+ syscon = entry;
+ break;
+ }
+ }
+
+ spin_unlock(&syscon_list_slock);
+
+ if (syscon)
+ return syscon->regmap;
+
syscon_np = of_find_compatible_node(NULL, NULL, s);
if (!syscon_np)
return ERR_PTR(-ENODEV);
@@ -196,6 +217,56 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle);

+/**
+ * syscon_register - Register a new syscon regmap
+ * @start: The starting memory address of the regmap
+ * @size: The size of the regmap in bytes
+ * @compatible: Compatible string used for lookup
+ *
+ * Returns: Pointer to a regmap or a negative error code.
+ */
+struct regmap *syscon_register(resource_size_t start, size_t size,
+ const char *compatible)
+{
+ struct regmap_config syscon_config = syscon_regmap_config;
+ struct syscon *syscon;
+ void __iomem *base;
+ int err;
+
+ syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
+ if (!syscon)
+ return ERR_PTR(-ENOMEM);
+
+ base = ioremap(start, size);
+ if (!base) {
+ err = -ENOMEM;
+ goto err_free_syscon;
+ }
+
+ strncpy(syscon->compatible, compatible, SYSCON_COMPATIBLE_SIZE);
+
+ syscon_config.max_register = size - 1;
+ syscon->regmap = regmap_init_mmio(NULL, base, &syscon_config);
+ if (IS_ERR(syscon->regmap)) {
+ err = PTR_ERR(syscon->regmap);
+ goto err_iounmap;
+ }
+
+ spin_lock(&syscon_list_slock);
+ list_add_tail(&syscon->list, &syscon_list);
+ spin_unlock(&syscon_list_slock);
+
+ return syscon->regmap;
+
+err_iounmap:
+ iounmap(base);
+err_free_syscon:
+ kfree(syscon);
+
+ return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(syscon_register);
+
static int syscon_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 40a76b9..ce531b4 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -27,6 +27,8 @@ extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s);
extern struct regmap *syscon_regmap_lookup_by_phandle(
struct device_node *np,
const char *property);
+extern struct regmap *syscon_register(resource_size_t start, size_t size,
+ const char *compatible);
#else
static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
{
@@ -49,6 +51,13 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle(
{
return ERR_PTR(-ENOTSUPP);
}
+
+static inline struct regmap *syscon_register(resource_size_t start,
+ size_t size,
+ const char *id)
+{
+ return ERR_PTR(-ENOTSUPP);
+}
#endif

#endif /* __LINUX_MFD_SYSCON_H__ */
--
2.7.4


2018-01-20 03:22:55

by David Lechner

[permalink] [raw]
Subject: [PATCH 2/6] phy: da8xx-usb: Always check for syscon compatible

This slightly changes the logic for getting the CFGCHIP syscon register.
We now always call syscon_regmap_lookup_by_compatible() even when not
using device tree. This is in preparation for some changes in how the
CFGCHIP syscon regmap is registered on da8xx platforms.

Signed-off-by: David Lechner <[email protected]>
---
drivers/phy/ti/phy-da8xx-usb.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/ti/phy-da8xx-usb.c b/drivers/phy/ti/phy-da8xx-usb.c
index 1b82bff..d463587 100644
--- a/drivers/phy/ti/phy-da8xx-usb.c
+++ b/drivers/phy/ti/phy-da8xx-usb.c
@@ -152,10 +152,8 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
if (!d_phy)
return -ENOMEM;

- if (node)
- d_phy->regmap = syscon_regmap_lookup_by_compatible(
- "ti,da830-cfgchip");
- else
+ d_phy->regmap = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip");
+ if (IS_ERR(d_phy->regmap))
d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon");
if (IS_ERR(d_phy->regmap)) {
dev_err(dev, "Failed to get syscon\n");
--
2.7.4


2018-01-20 03:22:56

by David Lechner

[permalink] [raw]
Subject: [PATCH 4/6] ARM: davinci: move davinci_clk_init() to init_time

This moves the call of davinci_clk_init() from map_io to init_time for all
boards.

This is the proper place to init clocks. This is also done in preparation
for moving to the common clock framework.

dm646x is a special case because we need to handle different ref_clk rates
depending on which board is being used. The clock init in this case is
modified to set the rate before registering the clocks instead of using
davinci_set_refclk_rate() to recalculate the entire clock tree after all
of the clocks are registered.

Also, the cpu_clks field is removed from struct davinci_soc_info since it
is no longer needed.

Signed-off-by: David Lechner <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 2 +-
arch/arm/mach-davinci/board-da850-evm.c | 2 +-
arch/arm/mach-davinci/board-dm355-evm.c | 2 +-
arch/arm/mach-davinci/board-dm355-leopard.c | 2 +-
arch/arm/mach-davinci/board-dm365-evm.c | 2 +-
arch/arm/mach-davinci/board-dm644x-evm.c | 2 +-
arch/arm/mach-davinci/board-dm646x-evm.c | 19 +++++++++++++------
arch/arm/mach-davinci/board-mityomapl138.c | 2 +-
arch/arm/mach-davinci/board-neuros-osd2.c | 2 +-
arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +-
arch/arm/mach-davinci/board-sffsdr.c | 2 +-
arch/arm/mach-davinci/da830.c | 7 +++++--
arch/arm/mach-davinci/da850.c | 7 +++++--
arch/arm/mach-davinci/da8xx-dt.c | 2 +-
arch/arm/mach-davinci/davinci.h | 4 ++++
arch/arm/mach-davinci/dm355.c | 8 ++++++--
arch/arm/mach-davinci/dm365.c | 8 ++++++--
arch/arm/mach-davinci/dm644x.c | 8 ++++++--
arch/arm/mach-davinci/dm646x.c | 22 +++++++++++-----------
arch/arm/mach-davinci/include/mach/common.h | 1 -
arch/arm/mach-davinci/include/mach/da8xx.h | 3 +++
21 files changed, 70 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index a58bfca..7adf009 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -638,7 +638,7 @@ MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
.atag_offset = 0x100,
.map_io = da830_evm_map_io,
.init_irq = cp_intc_init,
- .init_time = davinci_timer_init,
+ .init_time = da830_init_time,
.init_machine = da830_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 9daeab3..d9d423d 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1481,7 +1481,7 @@ MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
.atag_offset = 0x100,
.map_io = da850_evm_map_io,
.init_irq = cp_intc_init,
- .init_time = davinci_timer_init,
+ .init_time = da850_init_time,
.init_machine = da850_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index d60d998..3c15cb7 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -416,7 +416,7 @@ MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
.atag_offset = 0x100,
.map_io = dm355_evm_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm355_init_time,
.init_machine = dm355_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index 1e7e9b8..3ebc89d 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -271,7 +271,7 @@ MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
.atag_offset = 0x100,
.map_io = dm355_leopard_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm355_init_time,
.init_machine = dm355_leopard_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 17b2c29..3daeac7 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -774,7 +774,7 @@ MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
.atag_offset = 0x100,
.map_io = dm365_evm_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm365_init_time,
.init_machine = dm365_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 5e1afc2..8d8c4ab 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -817,7 +817,7 @@ MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
.atag_offset = 0x100,
.map_io = davinci_evm_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm644x_init_time,
.init_machine = davinci_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 003bbe5..2d37f5b 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -44,10 +44,8 @@
#include <mach/common.h>
#include <mach/irqs.h>
#include <mach/serial.h>
-#include <mach/clock.h>

#include "davinci.h"
-#include "clock.h"

#define NAND_BLOCK_SIZE SZ_128K

@@ -716,14 +714,23 @@ static void __init evm_init_i2c(void)
}
#endif

+#define DM646X_REF_FREQ 27000000
+#define DM646X_AUX_FREQ 24000000
#define DM6467T_EVM_REF_FREQ 33000000

static void __init davinci_map_io(void)
{
dm646x_init();
+}

- if (machine_is_davinci_dm6467tevm())
- davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
+static void __init dm646x_evm_init_time(void)
+{
+ dm646x_init_time(DM646X_REF_FREQ, DM646X_AUX_FREQ);
+}
+
+static void __init dm6467t_evm_init_time(void)
+{
+ dm646x_init_time(DM6467T_EVM_REF_FREQ, DM646X_AUX_FREQ);
}

#define DM646X_EVM_PHY_ID "davinci_mdio-0:01"
@@ -797,7 +804,7 @@ MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
.atag_offset = 0x100,
.map_io = davinci_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm646x_evm_init_time,
.init_machine = evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
@@ -807,7 +814,7 @@ MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
.atag_offset = 0x100,
.map_io = davinci_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm6467t_evm_init_time,
.init_machine = evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 0b23cf3..f9a725a 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -570,7 +570,7 @@ MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808")
.atag_offset = 0x100,
.map_io = mityomapl138_map_io,
.init_irq = cp_intc_init,
- .init_time = davinci_timer_init,
+ .init_time = da850_init_time,
.init_machine = mityomapl138_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 51a3ae1..f287577 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -227,7 +227,7 @@ MACHINE_START(NEUROS_OSD2, "Neuros OSD2")
.atag_offset = 0x100,
.map_io = davinci_ntosd2_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm644x_init_time,
.init_machine = davinci_ntosd2_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index 88ab45c..bc8a747 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -334,7 +334,7 @@ MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
.atag_offset = 0x100,
.map_io = omapl138_hawk_map_io,
.init_irq = cp_intc_init,
- .init_time = davinci_timer_init,
+ .init_time = da850_init_time,
.init_machine = omapl138_hawk_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index 1f02d4e..2922da9 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -150,7 +150,7 @@ MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
.atag_offset = 0x100,
.map_io = davinci_sffsdr_map_io,
.init_irq = davinci_irq_init,
- .init_time = davinci_timer_init,
+ .init_time = dm644x_init_time,
.init_machine = davinci_sffsdr_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 57ab18c..350d767 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1200,7 +1200,6 @@ static const struct davinci_soc_info davinci_soc_info_da830 = {
.jtag_id_reg = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
.ids = da830_ids,
.ids_num = ARRAY_SIZE(da830_ids),
- .cpu_clks = da830_clks,
.psc_bases = da830_psc_bases,
.psc_bases_num = ARRAY_SIZE(da830_psc_bases),
.pinmux_base = DA8XX_SYSCFG0_BASE + 0x120,
@@ -1220,6 +1219,10 @@ void __init da830_init(void)

da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module");
+}

- davinci_clk_init(davinci_soc_info_da830.cpu_clks);
+void __init da830_init_time(void)
+{
+ davinci_clk_init(da830_clks);
+ davinci_timer_init();
}
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index aa37cbd..34117e61 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1353,7 +1353,6 @@ static const struct davinci_soc_info davinci_soc_info_da850 = {
.jtag_id_reg = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
.ids = da850_ids,
.ids_num = ARRAY_SIZE(da850_ids),
- .cpu_clks = da850_clks,
.psc_bases = da850_psc_bases,
.psc_bases_num = ARRAY_SIZE(da850_psc_bases),
.pinmux_base = DA8XX_SYSCFG0_BASE + 0x120,
@@ -1392,6 +1391,10 @@ void __init da850_init(void)
v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
__raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
+}

- davinci_clk_init(davinci_soc_info_da850.cpu_clks);
+void __init da850_init_time(void)
+{
+ davinci_clk_init(da850_clks);
+ davinci_timer_init();
}
diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
index 779e8ce..ab199f4 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -96,7 +96,7 @@ static const char *const da850_boards_compat[] __initconst = {

DT_MACHINE_START(DA850_DT, "Generic DA850/OMAP-L138/AM18x")
.map_io = da850_init,
- .init_time = davinci_timer_init,
+ .init_time = da850_init_time,
.init_machine = da850_init_machine,
.dt_compat = da850_boards_compat,
.init_late = davinci_init_late,
diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
index c62b90c..270cef8 100644
--- a/arch/arm/mach-davinci/davinci.h
+++ b/arch/arm/mach-davinci/davinci.h
@@ -83,6 +83,7 @@ int davinci_init_wdt(void);

/* DM355 function declarations */
void dm355_init(void);
+void dm355_init_time(void);
void dm355_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
void dm355_init_asp1(u32 evt_enable);
@@ -91,6 +92,7 @@ int dm355_gpio_register(void);

/* DM365 function declarations */
void dm365_init(void);
+void dm365_init_time(void);
void dm365_init_asp(void);
void dm365_init_vc(void);
void dm365_init_ks(struct davinci_ks_platform_data *pdata);
@@ -102,12 +104,14 @@ int dm365_gpio_register(void);

/* DM644x function declarations */
void dm644x_init(void);
+void dm644x_init_time(void);
void dm644x_init_asp(void);
int dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
int dm644x_gpio_register(void);

/* DM646x function declarations */
void dm646x_init(void);
+void dm646x_init_time(unsigned long ref_clk_rate, unsigned long aux_clkin_rate);
void dm646x_init_mcasp0(struct snd_platform_data *pdata);
void dm646x_init_mcasp1(struct snd_platform_data *pdata);
int dm646x_init_edma(struct edma_rsv_info *rsv);
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 938747f..f294804 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -1012,7 +1012,6 @@ static const struct davinci_soc_info davinci_soc_info_dm355 = {
.jtag_id_reg = 0x01c40028,
.ids = dm355_ids,
.ids_num = ARRAY_SIZE(dm355_ids),
- .cpu_clks = dm355_clks,
.psc_bases = dm355_psc_bases,
.psc_bases_num = ARRAY_SIZE(dm355_psc_bases),
.pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
@@ -1043,7 +1042,12 @@ void __init dm355_init(void)
{
davinci_common_init(&davinci_soc_info_dm355);
davinci_map_sysmod();
- davinci_clk_init(davinci_soc_info_dm355.cpu_clks);
+}
+
+void __init dm355_init_time(void)
+{
+ davinci_clk_init(dm355_clks);
+ davinci_timer_init();
}

int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 5d9f96d..1e3df9d 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -1116,7 +1116,6 @@ static const struct davinci_soc_info davinci_soc_info_dm365 = {
.jtag_id_reg = 0x01c40028,
.ids = dm365_ids,
.ids_num = ARRAY_SIZE(dm365_ids),
- .cpu_clks = dm365_clks,
.psc_bases = dm365_psc_bases,
.psc_bases_num = ARRAY_SIZE(dm365_psc_bases),
.pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
@@ -1168,7 +1167,12 @@ void __init dm365_init(void)
{
davinci_common_init(&davinci_soc_info_dm365);
davinci_map_sysmod();
- davinci_clk_init(davinci_soc_info_dm365.cpu_clks);
+}
+
+void __init dm365_init_time(void)
+{
+ davinci_clk_init(dm365_clks);
+ davinci_timer_init();
}

static struct resource dm365_vpss_resources[] = {
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 6b41e1c..b409801 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -905,7 +905,6 @@ static const struct davinci_soc_info davinci_soc_info_dm644x = {
.jtag_id_reg = 0x01c40028,
.ids = dm644x_ids,
.ids_num = ARRAY_SIZE(dm644x_ids),
- .cpu_clks = dm644x_clks,
.psc_bases = dm644x_psc_bases,
.psc_bases_num = ARRAY_SIZE(dm644x_psc_bases),
.pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
@@ -931,7 +930,12 @@ void __init dm644x_init(void)
{
davinci_common_init(&davinci_soc_info_dm644x);
davinci_map_sysmod();
- davinci_clk_init(davinci_soc_info_dm644x.cpu_clks);
+}
+
+void __init dm644x_init_time(void)
+{
+ davinci_clk_init(dm644x_clks);
+ davinci_timer_init();
}

int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 6fc06a6..109ab1f 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -39,12 +39,6 @@
#define VSCLKDIS_MASK (BIT_MASK(11) | BIT_MASK(10) | BIT_MASK(9) |\
BIT_MASK(8))

-/*
- * Device specific clocks
- */
-#define DM646X_REF_FREQ 27000000
-#define DM646X_AUX_FREQ 24000000
-
#define DM646X_EMAC_BASE 0x01c80000
#define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
#define DM646X_EMAC_CNTRL_OFFSET 0x0000
@@ -64,13 +58,12 @@ static struct pll_data pll2_data = {

static struct clk ref_clk = {
.name = "ref_clk",
- .rate = DM646X_REF_FREQ,
- .set_rate = davinci_simple_set_rate,
+ /* rate is initialized in dm646x_init_time() */
};

static struct clk aux_clkin = {
.name = "aux_clkin",
- .rate = DM646X_AUX_FREQ,
+ /* rate is initialized in dm646x_init_time() */
};

static struct clk pll1_clk = {
@@ -888,7 +881,6 @@ static const struct davinci_soc_info davinci_soc_info_dm646x = {
.jtag_id_reg = 0x01c40028,
.ids = dm646x_ids,
.ids_num = ARRAY_SIZE(dm646x_ids),
- .cpu_clks = dm646x_clks,
.psc_bases = dm646x_psc_bases,
.psc_bases_num = ARRAY_SIZE(dm646x_psc_bases),
.pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
@@ -956,7 +948,15 @@ void __init dm646x_init(void)
{
davinci_common_init(&davinci_soc_info_dm646x);
davinci_map_sysmod();
- davinci_clk_init(davinci_soc_info_dm646x.cpu_clks);
+}
+
+void __init dm646x_init_time(unsigned long ref_clk_rate,
+ unsigned long aux_clkin_rate)
+{
+ ref_clk.rate = ref_clk_rate;
+ aux_clkin.rate = aux_clkin_rate;
+ davinci_clk_init(dm646x_clks);
+ davinci_timer_init();
}

static int __init dm646x_init_devices(void)
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index 19b9346..f0d5e858 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -53,7 +53,6 @@ struct davinci_soc_info {
u32 jtag_id_reg;
struct davinci_id *ids;
unsigned long ids_num;
- struct clk_lookup *cpu_clks;
u32 *psc_bases;
unsigned long psc_bases_num;
u32 pinmux_base;
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 751d2ac..3481a0d 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -87,7 +87,10 @@ extern unsigned int da850_max_speed;
#define DA8XX_ARM_RAM_BASE 0xffff0000

void da830_init(void);
+void da830_init_time(void);
+
void da850_init(void);
+void da850_init_time(void);

int da830_register_edma(struct edma_rsv_info *rsv);
int da850_register_edma(struct edma_rsv_info *rsv[2]);
--
2.7.4


2018-01-20 03:23:32

by David Lechner

[permalink] [raw]
Subject: [PATCH 3/6] phy: da8xx-usb: rename clock con_ids

This renames the clock con_ids in the DA8XX USB PHY driver as well as
the matching names in the mach clock registration code.

This is in preparation for using device tree clocks where these names
will become part of the device tree bindings. The new names more closely
match the names used in the USB clock diagram in the SoC TRM.

Signed-off-by: David Lechner <[email protected]>
---
arch/arm/mach-davinci/usb-da8xx.c | 12 ++++++------
drivers/phy/ti/phy-da8xx-usb.c | 8 ++++----
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c
index d480a02..fb31f6e 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -256,14 +256,14 @@ static int usb20_phy_clk_set_parent(struct clk *clk, struct clk *parent)
}

static struct clk usb20_phy_clk = {
- .name = "usb20_phy",
+ .name = "usb0_clk48",
.clk_enable = usb20_phy_clk_enable,
.clk_disable = usb20_phy_clk_disable,
.set_parent = usb20_phy_clk_set_parent,
};

static struct clk_lookup usb20_phy_clk_lookup =
- CLK("da8xx-usb-phy", "usb20_phy", &usb20_phy_clk);
+ CLK("da8xx-usb-phy", "usb0_clk48", &usb20_phy_clk);

/**
* da8xx_register_usb20_phy_clk - register USB0PHYCLKMUX clock
@@ -320,18 +320,18 @@ static int usb11_phy_clk_set_parent(struct clk *clk, struct clk *parent)
}

static struct clk usb11_phy_clk = {
- .name = "usb11_phy",
+ .name = "usb1_clk48",
.set_parent = usb11_phy_clk_set_parent,
};

static struct clk_lookup usb11_phy_clk_lookup =
- CLK("da8xx-usb-phy", "usb11_phy", &usb11_phy_clk);
+ CLK("da8xx-usb-phy", "usb1_clk48", &usb11_phy_clk);

/**
* da8xx_register_usb11_phy_clk - register USB1PHYCLKMUX clock
*
* @use_usb_refclkin: Selects the parent clock - either "usb_refclkin" if true
- * or "usb20_phy" if false.
+ * or "usb0_clk48" if false.
*/
int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin)
{
@@ -341,7 +341,7 @@ int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin)
if (use_usb_refclkin)
parent = clk_get(NULL, "usb_refclkin");
else
- parent = clk_get(&da8xx_usb_phy.dev, "usb20_phy");
+ parent = clk_get(&da8xx_usb_phy.dev, "usb0_clk48");
if (IS_ERR(parent))
return PTR_ERR(parent);

diff --git a/drivers/phy/ti/phy-da8xx-usb.c b/drivers/phy/ti/phy-da8xx-usb.c
index d463587..4daa905 100644
--- a/drivers/phy/ti/phy-da8xx-usb.c
+++ b/drivers/phy/ti/phy-da8xx-usb.c
@@ -160,15 +160,15 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
return PTR_ERR(d_phy->regmap);
}

- d_phy->usb11_clk = devm_clk_get(dev, "usb11_phy");
+ d_phy->usb11_clk = devm_clk_get(dev, "usb1_clk48");
if (IS_ERR(d_phy->usb11_clk)) {
- dev_err(dev, "Failed to get usb11_phy clock\n");
+ dev_err(dev, "Failed to get usb1_clk48\n");
return PTR_ERR(d_phy->usb11_clk);
}

- d_phy->usb20_clk = devm_clk_get(dev, "usb20_phy");
+ d_phy->usb20_clk = devm_clk_get(dev, "usb0_clk48");
if (IS_ERR(d_phy->usb20_clk)) {
- dev_err(dev, "Failed to get usb20_phy clock\n");
+ dev_err(dev, "Failed to get usb0_clk48\n");
return PTR_ERR(d_phy->usb20_clk);
}

--
2.7.4


2018-01-20 03:23:53

by David Lechner

[permalink] [raw]
Subject: [PATCH 5/6] ARM: da8xx: Move CFGCHIP registration to init_time

This moves the registration of the CFGCHIP syscon device to the
init_time callback. This is in preparation of moving to the common
clock framework. There are a number of clocks in this syscon device
so it will be needed at this point in boot to register the clocks.

In da850.c also move the PLL unlock code to make use of the CFGCHIP
regmap. It makes more sense to have it in init_time anyway since it
is related to clocks.

Signed-off-by: David Lechner <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 4 ----
arch/arm/mach-davinci/board-da850-evm.c | 4 ----
arch/arm/mach-davinci/board-mityomapl138.c | 4 ----
arch/arm/mach-davinci/board-omapl138-hawk.c | 4 ----
arch/arm/mach-davinci/da830.c | 1 +
arch/arm/mach-davinci/da850.c | 28 ++++++++++++----------------
arch/arm/mach-davinci/devices-da8xx.c | 29 ++++-------------------------
arch/arm/mach-davinci/include/mach/da8xx.h | 3 ++-
8 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 7adf009..3a1a86c 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -551,10 +551,6 @@ static __init void da830_evm_init(void)
struct davinci_soc_info *soc_info = &davinci_soc_info;
int ret;

- ret = da8xx_register_cfgchip();
- if (ret)
- pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
-
ret = da830_register_gpio();
if (ret)
pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index d9d423d..3063478 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1334,10 +1334,6 @@ static __init void da850_evm_init(void)
{
int ret;

- ret = da8xx_register_cfgchip();
- if (ret)
- pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
-
ret = da850_register_gpio();
if (ret)
pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index f9a725a..d1c8548 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -502,10 +502,6 @@ static void __init mityomapl138_init(void)
{
int ret;

- ret = da8xx_register_cfgchip();
- if (ret)
- pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
-
/* for now, no special EDMA channels are reserved */
ret = da850_register_edma(NULL);
if (ret)
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index bc8a747..e2ba9da 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -281,10 +281,6 @@ static __init void omapl138_hawk_init(void)
{
int ret;

- ret = da8xx_register_cfgchip();
- if (ret)
- pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
-
ret = da850_register_gpio();
if (ret)
pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 350d767..39de5a6 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1223,6 +1223,7 @@ void __init da830_init(void)

void __init da830_init_time(void)
{
+ da8xx_register_cfgchip();
davinci_clk_init(da830_clks);
davinci_timer_init();
}
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 34117e61..5c86d77 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -17,6 +17,8 @@
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/cpufreq.h>
+#include <linux/mfd/da8xx-cfgchip.h>
+#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/platform_data/gpio-davinci.h>

@@ -40,10 +42,6 @@

#define DA850_REF_FREQ 24000000

-#define CFGCHIP3_ASYNC3_CLKSRC BIT(4)
-#define CFGCHIP3_PLL1_MASTER_LOCK BIT(5)
-#define CFGCHIP0_PLL_MASTER_LOCK BIT(4)
-
static int da850_set_armrate(struct clk *clk, unsigned long rate);
static int da850_round_armrate(struct clk *clk, unsigned long rate);
static int da850_set_pll0rate(struct clk *clk, unsigned long armrate);
@@ -1370,8 +1368,6 @@ static const struct davinci_soc_info davinci_soc_info_da850 = {

void __init da850_init(void)
{
- unsigned int v;
-
davinci_common_init(&davinci_soc_info_da850);

da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
@@ -1381,20 +1377,20 @@ void __init da850_init(void)
da8xx_syscfg1_base = ioremap(DA8XX_SYSCFG1_BASE, SZ_4K);
if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module"))
return;
-
- /* Unlock writing to PLL0 registers */
- v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG));
- v &= ~CFGCHIP0_PLL_MASTER_LOCK;
- __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG));
-
- /* Unlock writing to PLL1 registers */
- v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
- v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
- __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
}

void __init da850_init_time(void)
{
+ struct regmap *cfgchip;
+
+ cfgchip = da8xx_register_cfgchip();
+ if (WARN(IS_ERR(cfgchip), "failed to register CFGCHIP syscon"))
+ return;
+
+ /* Unlock writing to PLL registers */
+ regmap_write_bits(cfgchip, CFGCHIP(0), CFGCHIP0_PLL_MASTER_LOCK, 0);
+ regmap_write_bits(cfgchip, CFGCHIP(3), CFGCHIP3_PLL1_MASTER_LOCK, 0);
+
davinci_clk_init(da850_clks);
davinci_timer_init();
}
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index fe5e15a..44cda0a 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -11,7 +11,7 @@
* (at your option) any later version.
*/
#include <linux/init.h>
-#include <linux/platform_data/syscon.h>
+#include <linux/mfd/syscon.h>
#include <linux/platform_device.h>
#include <linux/dma-contiguous.h>
#include <linux/serial_8250.h>
@@ -1105,29 +1105,8 @@ int __init da850_register_sata(unsigned long refclkpn)
}
#endif

-static struct syscon_platform_data da8xx_cfgchip_platform_data = {
- .label = "cfgchip",
-};
-
-static struct resource da8xx_cfgchip_resources[] = {
- {
- .start = DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP0_REG,
- .end = DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP4_REG + 3,
- .flags = IORESOURCE_MEM,
- },
-};
-
-static struct platform_device da8xx_cfgchip_device = {
- .name = "syscon",
- .id = -1,
- .dev = {
- .platform_data = &da8xx_cfgchip_platform_data,
- },
- .num_resources = ARRAY_SIZE(da8xx_cfgchip_resources),
- .resource = da8xx_cfgchip_resources,
-};
-
-int __init da8xx_register_cfgchip(void)
+struct regmap * __init da8xx_register_cfgchip(void)
{
- return platform_device_register(&da8xx_cfgchip_device);
+ return syscon_register(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP0_REG,
+ sizeof(u32) * 5, "ti,da830-cfgchip");
}
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 3481a0d..7a40ec7 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -18,6 +18,7 @@
#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
#include <linux/reboot.h>
+#include <linux/regmap.h>
#include <linux/videodev2.h>

#include <mach/serial.h>
@@ -125,7 +126,7 @@ void da8xx_rproc_reserve_cma(void);
int da8xx_register_rproc(void);
int da850_register_gpio(void);
int da830_register_gpio(void);
-int da8xx_register_cfgchip(void);
+struct regmap *da8xx_register_cfgchip(void);

extern struct platform_device da8xx_serial_device[];
extern struct emac_platform_data da8xx_emac_pdata;
--
2.7.4


2018-01-20 03:24:00

by David Lechner

[permalink] [raw]
Subject: [PATCH 6/6] phy: da8xx-usb: drop use of syscon_regmap_lookup_by_pdevname()

This drops the use of syscon_regmap_lookup_by_pdevname() from the
DA8XX USB PHY driver. There are no longer any boards that register
a syscon platform device, so it is no longer needed.

Signed-off-by: David Lechner <[email protected]>
---
drivers/phy/ti/phy-da8xx-usb.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/phy/ti/phy-da8xx-usb.c b/drivers/phy/ti/phy-da8xx-usb.c
index 4daa905..76f4fe9 100644
--- a/drivers/phy/ti/phy-da8xx-usb.c
+++ b/drivers/phy/ti/phy-da8xx-usb.c
@@ -153,8 +153,6 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
return -ENOMEM;

d_phy->regmap = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip");
- if (IS_ERR(d_phy->regmap))
- d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon");
if (IS_ERR(d_phy->regmap)) {
dev_err(dev, "Failed to get syscon\n");
return PTR_ERR(d_phy->regmap);
--
2.7.4


2018-01-22 10:56:09

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH 1/6] mfd: syscon: Add syscon_register() function

On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
> This adds a new syscon_register() function that creates a new syscon
> regmap and adds it to the lookup list.
>
> This function serves two purposes:
>
> 1. This is needed for platforms without device tree support where the
> syscon regmap is needed in early boot (e.g. clocks), because using a
> platform driver at this point in boot is not an option.

Is this because platform_device_register() of the syscon device fails
when called early on? It will be nice to document the exact failure case
here (at least the return value) so its clear what the issue is.

> 2. It allows other drivers to use syscon_regmap_lookup_by_compatible()
> for both device tree and non-DT platforms instead of having to have
> a separate case that calls syscon_regmap_lookup_by_pdevname().

"compatible" is a very device-tree specific terminology so I am afraid
this is will actually turn out to be confusing.

So, if we are doing this, I would rather be more explicit about it:

/*
* registers a "global" syscon "device", usually not backed by a real
* device. To be used only in cases where the syscon is not
* related to any actual device, like system clocks, for example.
*
* name passed here must be globally unique.
*/
struct regmap *syscon_register_by_name(resource_size_t start, size_t
size, const char *name);

and

struct regmap *syscon_regmap_lookup_by_name(const char *name);

I understand, with this the driver becomes little more complicated and
DT and non-DT cases still need to be handled differently. But I think
thats not the main issue you are trying to solve.

>
> Signed-off-by: David Lechner <[email protected]>

Thanks,
Sekhar

2018-01-22 11:09:48

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/6] mfd: syscon: Add syscon_register() function

On Mon, Jan 22, 2018 at 11:53 AM, Sekhar Nori <[email protected]> wrote:
> On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
>> This adds a new syscon_register() function that creates a new syscon
>> regmap and adds it to the lookup list.
>
> /*
> * registers a "global" syscon "device", usually not backed by a real
> * device. To be used only in cases where the syscon is not
> * related to any actual device, like system clocks, for example.
> *
> * name passed here must be globally unique.
> */
> struct regmap *syscon_register_by_name(resource_size_t start, size_t
> size, const char *name);
>
> and
>
> struct regmap *syscon_regmap_lookup_by_name(const char *name);
>
> I understand, with this the driver becomes little more complicated and
> DT and non-DT cases still need to be handled differently. But I think
> thats not the main issue you are trying to solve.

I think the easiest way to handle this in traditional board files is to use
a platform_data structure: when the platform registers the syscon,
it holds a pointer to the regmap and can simply add pass it to any
device using the syscon through platform_data. The driver using it
then does:

if (dev->of_node) {
priv->regmap = syscon_regmap_lookup_by_phandle(...);
else
priv->regmap = pdata->regmap;

At some point, we had a syscon_regmap_lookup_by_pdevname()
that was introduced for a similar case, but we should just kill that
now, after the platform that needed it is DT-only.

Arnd

2018-01-22 11:15:48

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH 0/6] ARM: davinci: common clock prep work

On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
> This series contains some changes needed for the conversion of arch/arm/mach-
> davinci to the common clock framework.
>
> Most of the boards in mach-davinci do not have device tree support. However,
> CFGCHIP, which is a syscon regmap, is needed during clock init in early boot.
> Using a platform device for the syscon at this point is not an option. So,
> this series introduces a new way to register a syscon regmap on non-DT systems.
>
> The DA8XX USB PHY driver is a consumer of the CFGCHIP syscon regmap, so some
> changes are needed in that driver as well since we are removing the syscon
> platform devices. The patch "phy: da8xx-usb: rename clock con_ids" doesn't
> have anything to do with syscon, but I included in this series because we are
> touching PHY code here anyway and it is also a dependency for the upcoming
> common clock framework conversion changes.
>
> Maintainers, please coordinate with Sekhar before committing. We will probably
> want everything to go through the linux-davinci tree if possible.

You should wait for some more feedback before resending anything, but I
think it will be easier to reivew/accept this if the changes are just
related to removal of "syscon" platform device from devices-da8xx.c.

It _seems_ like this series does more than just that, and I hope it can
be pared down.

Thanks,
Sekhar

2018-01-22 11:41:36

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH 1/6] mfd: syscon: Add syscon_register() function

On Monday 22 January 2018 04:38 PM, Arnd Bergmann wrote:
> On Mon, Jan 22, 2018 at 11:53 AM, Sekhar Nori <[email protected]> wrote:
>> On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
>>> This adds a new syscon_register() function that creates a new syscon
>>> regmap and adds it to the lookup list.
>>
>> /*
>> * registers a "global" syscon "device", usually not backed by a real
>> * device. To be used only in cases where the syscon is not
>> * related to any actual device, like system clocks, for example.
>> *
>> * name passed here must be globally unique.
>> */
>> struct regmap *syscon_register_by_name(resource_size_t start, size_t
>> size, const char *name);
>>
>> and
>>
>> struct regmap *syscon_regmap_lookup_by_name(const char *name);
>>
>> I understand, with this the driver becomes little more complicated and
>> DT and non-DT cases still need to be handled differently. But I think
>> thats not the main issue you are trying to solve.
>
> I think the easiest way to handle this in traditional board files is to use
> a platform_data structure: when the platform registers the syscon,
> it holds a pointer to the regmap and can simply add pass it to any
> device using the syscon through platform_data. The driver using it
> then does:
>
> if (dev->of_node) {
> priv->regmap = syscon_regmap_lookup_by_phandle(...);
> else
> priv->regmap = pdata->regmap;

I think this works as well and does not need any new API. For clocks,
there is no platform data AFAICT, so it will have to be whatever
structure is being used to pass clock info to CCF driver (like perhaps
an addition parameter to da850_pll_clk_init() in David's under-review
DaVinci CCF conversion series).

> At some point, we had a syscon_regmap_lookup_by_pdevname()
> that was introduced for a similar case, but we should just kill that
> now, after the platform that needed it is DT-only.

Yeah, I just noticed that too. syscon_regmap_lookup_by_pdevname has only
two callers in kernel. The call from clps711x.c UART driver does not
seem to be needed anymore after clps711x was converted to DT-only in v4.8

The other user is phy-da8xx-usb.c which this series is trying to get rid
of. So, perhaps syscon_regmap_lookup_by_pdevname() should be dropped by
v2 of this series.

Thanks,
Sekhar

2018-01-22 16:49:54

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 1/6] mfd: syscon: Add syscon_register() function

On 01/22/2018 05:39 AM, Sekhar Nori wrote:
> On Monday 22 January 2018 04:38 PM, Arnd Bergmann wrote:
>> On Mon, Jan 22, 2018 at 11:53 AM, Sekhar Nori <[email protected]> wrote:
>>> On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
>>>> This adds a new syscon_register() function that creates a new syscon
>>>> regmap and adds it to the lookup list.
>>>
>>> /*
>>> * registers a "global" syscon "device", usually not backed by a real
>>> * device. To be used only in cases where the syscon is not
>>> * related to any actual device, like system clocks, for example.
>>> *
>>> * name passed here must be globally unique.
>>> */
>>> struct regmap *syscon_register_by_name(resource_size_t start, size_t
>>> size, const char *name);
>>>
>>> and
>>>
>>> struct regmap *syscon_regmap_lookup_by_name(const char *name);
>>>
>>> I understand, with this the driver becomes little more complicated and
>>> DT and non-DT cases still need to be handled differently. But I think
>>> thats not the main issue you are trying to solve.
>>
>> I think the easiest way to handle this in traditional board files is to use
>> a platform_data structure: when the platform registers the syscon,
>> it holds a pointer to the regmap and can simply add pass it to any
>> device using the syscon through platform_data. The driver using it
>> then does:
>>
>> if (dev->of_node) {
>> priv->regmap = syscon_regmap_lookup_by_phandle(...);
>> else
>> priv->regmap = pdata->regmap;
>
> I think this works as well and does not need any new API. For clocks,
> there is no platform data AFAICT, so it will have to be whatever
> structure is being used to pass clock info to CCF driver (like perhaps
> an addition parameter to da850_pll_clk_init() in David's under-review
> DaVinci CCF conversion series).
>
>> At some point, we had a syscon_regmap_lookup_by_pdevname()
>> that was introduced for a similar case, but we should just kill that
>> now, after the platform that needed it is DT-only.
>
> Yeah, I just noticed that too. syscon_regmap_lookup_by_pdevname has only
> two callers in kernel. The call from clps711x.c UART driver does not
> seem to be needed anymore after clps711x was converted to DT-only in v4.8
>
> The other user is phy-da8xx-usb.c which this series is trying to get rid
> of. So, perhaps syscon_regmap_lookup_by_pdevname() should be dropped by
> v2 of this series.
>

Sounds like a plan.

Sekhar, would you please have a look at [PATCH 4/6] "ARM: davinci: move
davinci_clk_init() to init_time" I've sent this 5 times already as part
of the common clock series. If it looks good to you, it would be nice if
you could pick it up so I don't have to keep resending it. :-)


2018-01-23 12:04:33

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH 4/6] ARM: davinci: move davinci_clk_init() to init_time

On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
> This moves the call of davinci_clk_init() from map_io to init_time for all
> boards.
>
> This is the proper place to init clocks. This is also done in preparation
> for moving to the common clock framework.
>
> dm646x is a special case because we need to handle different ref_clk rates
> depending on which board is being used. The clock init in this case is
> modified to set the rate before registering the clocks instead of using
> davinci_set_refclk_rate() to recalculate the entire clock tree after all
> of the clocks are registered.
>
> Also, the cpu_clks field is removed from struct davinci_soc_info since it
> is no longer needed.
>
> Signed-off-by: David Lechner <[email protected]>

Applied to my tree for v4.17

Thanks,
Sekhar

2018-01-23 23:41:10

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 0/6] ARM: davinci: common clock prep work

On 01/22/2018 05:13 AM, Sekhar Nori wrote:
> On Saturday 20 January 2018 08:50 AM, David Lechner wrote:
>> This series contains some changes needed for the conversion of arch/arm/mach-
>> davinci to the common clock framework.
>>
>> Most of the boards in mach-davinci do not have device tree support. However,
>> CFGCHIP, which is a syscon regmap, is needed during clock init in early boot.
>> Using a platform device for the syscon at this point is not an option. So,
>> this series introduces a new way to register a syscon regmap on non-DT systems.
>>
>> The DA8XX USB PHY driver is a consumer of the CFGCHIP syscon regmap, so some
>> changes are needed in that driver as well since we are removing the syscon
>> platform devices. The patch "phy: da8xx-usb: rename clock con_ids" doesn't
>> have anything to do with syscon, but I included in this series because we are
>> touching PHY code here anyway and it is also a dependency for the upcoming
>> common clock framework conversion changes.
>>
>> Maintainers, please coordinate with Sekhar before committing. We will probably
>> want everything to go through the linux-davinci tree if possible.
>
> You should wait for some more feedback before resending anything, but I
> think it will be easier to reivew/accept this if the changes are just
> related to removal of "syscon" platform device from devices-da8xx.c.
>
> It _seems_ like this series does more than just that, and I hope it can
> be pared down.
>

This series has been split out into "ARM: da8xx: use platform data for CFGCHIP
syscon regmap" [1] and "phy: da8xx-usb: rename clock con_ids" [2].

[1]: https://patchwork.kernel.org/patch/10181147/
[2]: https://patchwork.kernel.org/patch/10180897/