History

drivers/pinctrl: Add the concept of an "init" state

For pinctrl the "default" state is applied to pins before the driver's probe function is called. This is normally a sensible thing to do, but in some cases can cause problems. That's because the pins will change state before the driver is given a chance to program how those pins should behave. As an example you might have a regulator that is controlled by a PWM (output high = high voltage, output low = low voltage). The firmware might leave this pin as driven high. If we allow the driver core to reconfigure this pin as a PWM pin before the PWM's probe function runs then you might end up running at too low of a voltage while we probe. Let's introudce a new "init" state. If this is defined we'll set pinctrl to this state before probe and then "default" after probe (unless the driver explicitly changed states already). An alternative idea that was thought of was to use the pre-existing "sleep" or "idle" states and add a boolean property that we should start in that mode. This was not done because the "init" state is needed for correctness and those other states are only present (and only transitioned in to and out of) when (optional) power management is enabled. Changes in v3: - Moved declarations to pinctrl/devinfo.h - Fixed author/SoB Changes in v2: - Added comment to pinctrl_init_done() as per Linus W.

Douglas Anderson committed 11 years ago

Commit ef0eebc1 parent bac7f4c5 files · +65 −2Browse files

Showing the changes to include/linux/pinctrl (2 of 5 files). Show all

Unified · Split

2 files
  1. include/linux/pinctrl/devinfo.h +10 −0
  2. include/linux/pinctrl/pinctrl-state.h +8 −0
include/linux/pinctrl/devinfo.h+10−0
@@ -24,10 +24,14 @@ · 23 unmodified lines
2424 * struct dev_pin_info - pin state container for devices
2525 * @p: pinctrl handle for the containing device
2626 * @default_state: the default state for the handle, if found
27+ * @init_state: the state at probe time, if found
28+ * @sleep_state: the state at suspend time, if found
29+ * @idle_state: the state at idle (runtime suspend) time, if found
2730 */
2831 struct dev_pin_info {
2932 struct pinctrl *p;
3033 struct pinctrl_state *default_state;
34+ struct pinctrl_state *init_state;
3135 #ifdef CONFIG_PM
3236 struct pinctrl_state *sleep_state;
3337 struct pinctrl_state *idle_state;
@@ -35,6 +39,7 @@ struct dev_pin_info { · 1 unmodified line
3539 };
3640
3741 extern int pinctrl_bind_pins(struct device *dev);
42+extern int pinctrl_init_done(struct device *dev);
3843
3944 #else
4045
@@ -45,5 +50,10 @@ static inline int pinctrl_bind_pins(struct device *dev) · 4 unmodified lines
4550 return 0;
4651 }
4752
53+static inline int pinctrl_init_done(struct device *dev)
54+{
55+ return 0;
56+}
57+
4858 #endif /* CONFIG_PINCTRL */
4959 #endif /* PINCTRL_DEVINFO_H */
include/linux/pinctrl/pinctrl-state.h+8−0
@@ -9,6 +9,13 @@ · 8 unmodified lines
99 * hogs to configure muxing and pins at boot, and also as a state
1010 * to go into when returning from sleep and idle in
1111 * .pm_runtime_resume() or ordinary .resume() for example.
12+ * @PINCTRL_STATE_INIT: normally the pinctrl will be set to "default"
13+ * before the driver's probe() function is called. There are some
14+ * drivers where that is not appropriate becausing doing so would
15+ * glitch the pins. In those cases you can add an "init" pinctrl
16+ * which is the state of the pins before drive probe. After probe
17+ * if the pins are still in "init" state they'll be moved to
18+ * "default".
1219 * @PINCTRL_STATE_IDLE: the state the pinctrl handle shall be put into
1320 * when the pins are idle. This is a state where the system is relaxed
1421 * but not fully sleeping - some power may be on but clocks gated for
@@ -20,5 +27,6 @@ · 5 unmodified lines
2027 * ordinary .suspend() function.
2128 */
2229 #define PINCTRL_STATE_DEFAULT "default"
30+#define PINCTRL_STATE_INIT "init"
2331 #define PINCTRL_STATE_IDLE "idle"
2432 #define PINCTRL_STATE_SLEEP "sleep"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t