soc/tegra: Add support for IO pads power and voltage control
v8 cover soc/tegra: Add support for IO pads power and voltage control
The IO pins of Tegra SoCs are grouped for common control of IO interface like setting voltage signal levels and power state of the interface. The group is generally referred as IO pads. The power state and voltage control of IO pins can be done at IO pads level.
Tegra124 onwards IO pads support the power down state when system is active. The voltage levels on IO pads are auto detected on Tegra124/ Tegra132 but it is not in Tegra210. For Tegra210, the SW need to explicitly configure the voltage levels of IO pads
This series add the interface for the IO pad power state and voltage configurations. Modifies the client to use new APIs. Register the child devices to provide the client interface to configure IO pads power state and voltage from Device tree.
---
Changes from V2:
- Drop the pinctrl driver from series till pmc interfce is finalise.
- Move client to use the new APIs.
- Remove older APIs to configure IO rail and related macros.
Changes from V3:
- keep value to be unsigned long in the dpd_prepare.
- Make all pad_id/io_pad_id to id.
- tegra_io_pad_ -> tegra_io_pads
- dpd_bit -> bit, pwr_mask/bit to mask/bit.
- Rename function to tegra_io_pads_{set,get}_voltage_config
- Make the io pad tables common for all SoC.
- Make io_pads enums.
- Add enums for voltage.
- Drop patch of adding sub devs
Changes from V4:
- Change IO_PAD to IO_PADS.
- Change enum for voltage config
Changes from V5:
- Fix multiline comment.
- Use -EINVAL instead of -1 for nonsupported case and refactor APIs to convert io-pads to bit.
Changes from V7:
- Fix document format.
- Document public APIs.
- Fix the bit check.
- Add check of pad ID validatity.
Changes from V8:
- Fix comment style and typo.
- Rebase the series on 20160617
Laxman Dewangan (3):
soc/tegra: pmc: Use BIT macro for register field definition soc/tegra: pmc: Correct type of variable for tegra_pmc_readl() soc/tegra: pmc: Add support for IO pads power state and voltage
drivers/gpu/drm/tegra/sor.c | 8 +- drivers/soc/tegra/pmc.c | 273 +++++++++++++++++++++++++++++++++++--------- include/soc/tegra/pmc.h | 132 +++++++++++++++------ 3 files changed, 321 insertions(+), 92 deletions(-)
Signature · 1 line
2.1.4
PATCH v8 1/3 soc/tegra: pmc: Use BIT macro for register field definition
Use BIT macro for register field definition and make constant as U when using in shift operator like (3 << 30) to (3U << 30)
Changes from V1:
- Remove the indenting of line which is not for BIT macro usage. Changes from V2:
- None
Changes from V3:
- None
Changes from V4:
- Collected ack from Jon.
Changes from V5/V6:
- None
Changes from V7:
- Rebase on next-20160617
--- drivers/soc/tegra/pmc.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/soc/tegra/pmc.c +21 -21
@@ -45,29 +45,29 @@#include <soc/tegra/pmc.h> #define PMC_CNTRL 0x0 -#define PMC_CNTRL_SYSCLK_POLARITY (1 << 10)/* sys clk polarity */ -#define PMC_CNTRL_SYSCLK_OE (1 << 11)/* system clock enable */ -#define PMC_CNTRL_SIDE_EFFECT_LP0 (1 << 14)/* LP0 when CPU pwr gated */ -#define PMC_CNTRL_CPU_PWRREQ_POLARITY (1 << 15)/* CPU pwr req polarity */ -#define PMC_CNTRL_CPU_PWRREQ_OE (1 << 16)/* CPU pwr req enable */ -#define PMC_CNTRL_INTR_POLARITY (1 << 17)/* inverts INTR polarity */ -#define PMC_CNTRL_MAIN_RST (1 << 4) +#define PMC_CNTRL_SYSCLK_POLARITY BIT(10)/* sys clk polarity */ +#define PMC_CNTRL_SYSCLK_OE BIT(11)/* system clock enable */ +#define PMC_CNTRL_SIDE_EFFECT_LP0 BIT(14)/* LP0 when CPU pwr gated */ +#define PMC_CNTRL_CPU_PWRREQ_POLARITY BIT(15)/* CPU pwr req polarity */ +#define PMC_CNTRL_CPU_PWRREQ_OE BIT(16)/* CPU pwr req enable */ +#define PMC_CNTRL_INTR_POLARITY BIT(17)/* inverts INTR polarity */ +#define PMC_CNTRL_MAIN_RST BIT(4)#define DPD_SAMPLE 0x020 -#define DPD_SAMPLE_ENABLE (1 << 0) -#define DPD_SAMPLE_DISABLE (0 << 0) +#define DPD_SAMPLE_ENABLE BIT(0) +#define DPD_SAMPLE_DISABLE (0 << 0)#define PWRGATE_TOGGLE 0x30 -#define PWRGATE_TOGGLE_START (1 << 8) +#define PWRGATE_TOGGLE_START BIT(8)#define REMOVE_CLAMPING 0x34#define PWRGATE_STATUS 0x38#define PMC_SCRATCH0 0x50 -#define PMC_SCRATCH0_MODE_RECOVERY (1 << 31) -#define PMC_SCRATCH0_MODE_BOOTLOADER (1 << 30) -#define PMC_SCRATCH0_MODE_RCM (1 << 1) +#define PMC_SCRATCH0_MODE_RECOVERY BIT(31) +#define PMC_SCRATCH0_MODE_BOOTLOADER BIT(30) +#define PMC_SCRATCH0_MODE_RCM BIT(1)#define PMC_SCRATCH0_MODE_MASK (PMC_SCRATCH0_MODE_RECOVERY | \ PMC_SCRATCH0_MODE_BOOTLOADER | \ PMC_SCRATCH0_MODE_RCM)
@@ -78,8 +78,8 @@#define PMC_SCRATCH41 0x140#define PMC_SENSOR_CTRL 0x1b0 -#define PMC_SENSOR_CTRL_SCRATCH_WRITE (1 << 2) -#define PMC_SENSOR_CTRL_ENABLE_RST (1 << 1) +#define PMC_SENSOR_CTRL_SCRATCH_WRITE BIT(2) +#define PMC_SENSOR_CTRL_ENABLE_RST BIT(1)#define PMC_RST_STATUS 0x1b4#define PMC_RST_STATUS_POR 0
@@ -90,10 +90,10 @@#define PMC_RST_STATUS_AOTAG 5#define IO_DPD_REQ 0x1b8 -#define IO_DPD_REQ_CODE_IDLE (0 << 30) -#define IO_DPD_REQ_CODE_OFF (1 << 30) -#define IO_DPD_REQ_CODE_ON (2 << 30) -#define IO_DPD_REQ_CODE_MASK (3 << 30) +#define IO_DPD_REQ_CODE_IDLE (0 << 30) +#define IO_DPD_REQ_CODE_OFF (1U << 30) +#define IO_DPD_REQ_CODE_ON (2U << 30) +#define IO_DPD_REQ_CODE_MASK (3U << 30)#define IO_DPD_STATUS 0x1bc#define IO_DPD2_REQ 0x1c0
@@ -105,10 +105,10 @@#define PMC_SCRATCH54_ADDR_SHIFT 0#define PMC_SCRATCH55 0x25c -#define PMC_SCRATCH55_RESET_TEGRA (1 << 31) +#define PMC_SCRATCH55_RESET_TEGRA BIT(31)#define PMC_SCRATCH55_CNTRL_ID_SHIFT 27#define PMC_SCRATCH55_PINMUX_SHIFT 24 -#define PMC_SCRATCH55_16BITOP (1 << 15) +#define PMC_SCRATCH55_16BITOP BIT(15)#define PMC_SCRATCH55_CHECKSUM_SHIFT 16#define PMC_SCRATCH55_I2CSLV1_SHIFT 0
Signature · 1 line
2.1.4
PATCH v8 2/3 soc/tegra: pmc: Correct type of variable for tegra_pmc_readl()
In reply to Laxman DewanganThe function tegra_pmc_readl() returns the u32 type data and hence change the data type of variable where this data is stored to u32 type.
---
Changes from V1:
-This is new in series as per discussion on V1 series to use u32 for tegra_pmc_readl.
Changes from V2:
- Make unsigned long to u32 for some missed variable from V1.
Changes from V3:
- Revert back the value to ulong where time calcualtion is done.
Changes from V4:
- Collected RB from Jon.
Changes from V5/V6:
- None
--- drivers/soc/tegra/pmc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/soc/tegra/pmc.c +9 -7
@@ -885,10 +885,10 @@ static int tegra_io_rail_prepare(unsigned int id, unsigned long *request,return 0 ; } -static int tegra_io_rail_poll (unsigned long offset,unsigned long mask, -unsigned long val,unsigned long timeout) +static int tegra_io_rail_poll (unsigned long offset,u32 mask, +u32 val,unsigned long timeout) { -unsigned long value; +u32 value; timeout = jiffies +msecs_to_jiffies (timeout);
@@ -910,8 +910,9 @@ static void tegra_io_rail_unprepare(void)int tegra_io_rail_power_on (unsigned int id) { -unsigned long request, status, value; -unsigned int bit, mask; +unsigned long request, status; +unsigned int bit; +u32 value, mask;int err;mutex_lock (&pmc->powergates_lock);
@@ -945,8 +946,9 @@ EXPORT_SYMBOL(tegra_io_rail_power_on);int tegra_io_rail_power_off (unsigned int id) { -unsigned long request, status, value; -unsigned int bit, mask; +unsigned long request, status; +unsigned int bit; +u32 value, mask;int err;mutex_lock (&pmc->powergates_lock);
Signature · 1 line
2.1.4
PATCH v8 3/3 soc/tegra: pmc: Add support for IO pads power state and voltage
In reply to Laxman DewanganThe IO pins of Tegra SoCs are grouped for common control of IO interface like setting voltage signal levels and power state of the interface. The group is generally referred as IO pads. The power state and voltage control of IO pins can be done at IO pads level.
Tegra generation SoC supports the power down of IO pads when it is not used even in the active state of system. This saves power from that IO interface. Also it supports multiple voltage level in IO pins for interfacing on some of pads. The IO pad voltage is automatically detected till T124, hence SW need not to configure this. But from T210, the automatically detection logic has been removed, hence SW need to explicitly set the IO pad voltage into IO pad configuration registers.
Add support to set the power states and voltage level of the IO pads from client driver. The implementation for the APIs are in generic which is applicable for all generation os Tegra SoC.
IO pads ID and information of bit field for power state and voltage level controls are added for Tegra124, Tegra132 and Tegra210. The SOR driver is modified to use the new APIs.
---
Changes from V1:
This is reworked on earlier path to have separation between IO rails and io pads and add power state and voltage control APIs in single call.
Changes from V2:
- Remove the tegra_io_rail_power_off/on() apis and change client (sor) driver to use the new APIs for IO pad power.
- Remove the TEGRA_IO_RAIL_ macros.
Changes from V3:
- Make all pad_id/io_pad_id to id.
- tegra_io_pad_ -> tegra_io_pads
- dpd_bit -> bit, pwr_mask/bit to mask/bit.
- Rename function to tegra_io_pads_{set,get}_voltage_config
- Make the io pad tables common for all SoC.
- Make io_pads enums.
- Add enums for voltage.
Changes from V4:
- IO_PAD->IO_PADS
- TEGRA_IO_PADS_POWER_SOURCE_ -> TEGRA_IO_PADS_VCONF_
Changes from V5:
- Fix comment style to multi-line format.
- Use -EINVAL instead of -1 to refactor some of function as suggested by Jon.
Changes from V6:
- Doc style formatting.
- io pads id checks.
- Documenting public functions.
- Corrected error numbers.
Changes from V7:
- Fix typo and comment style.
--- drivers/gpu/drm/tegra/sor.c | 8 +- drivers/soc/tegra/pmc.c | 280 +++++++++++++++++++++++++++++++++++++++----- include/soc/tegra/pmc.h | 134 +++++++++++++++------ 3 files changed, 351 insertions(+), 71 deletions(-)
drivers/gpu/drm/tegra/sor.c +4 -4
@@ -1133,7 +1133,7 @@ static void tegra_sor_edp_disable(struct drm_encoder *encoder)dev_err (sor->dev,"failed to disable DP: %d\n" , err); } - err =tegra_io_rail_power_off (TEGRA_IO_RAIL_LVDS ); + err =tegra_io_pads_power_disable (TEGRA_IO_PADS_LVDS );if (err <0 )dev_err (sor->dev,"failed to power off I/O rail: %d\n" , err);
@@ -1295,7 +1295,7 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)tegra_sor_writel (sor, value,SOR_DP_PADCTL0 );/* step 2 */ - err =tegra_io_rail_power_on (TEGRA_IO_RAIL_LVDS ); + err =tegra_io_pads_power_enable (TEGRA_IO_PADS_LVDS );if (err <0 )dev_err (sor->dev,"failed to power on I/O rail: %d\n" , err);
@@ -1747,7 +1747,7 @@ static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)if (err <0 )dev_err (sor->dev,"failed to power down SOR: %d\n" , err); - err =tegra_io_rail_power_off (TEGRA_IO_RAIL_HDMI ); + err =tegra_io_pads_power_disable (TEGRA_IO_PADS_HDMI );if (err <0 )dev_err (sor->dev,"failed to power off HDMI rail: %d\n" , err);
@@ -1786,7 +1786,7 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder) div =clk_get_rate (sor->clk) /1000000 *4 ; - err =tegra_io_rail_power_on (TEGRA_IO_RAIL_HDMI ); + err =tegra_io_pads_power_enable (TEGRA_IO_PADS_HDMI );if (err <0 )dev_err (sor->dev,"failed to power on HDMI rail: %d\n" , err);
drivers/soc/tegra/pmc.c +250 -30
390 lines not on this page · raw message
include/soc/tegra/pmc.h +97 -37
156 lines not on this page · raw message
Signature · 1 line
2.1.4