[...] > >> >> >> The SDcard for Keem Bay SOC does not have its own voltage regulator. > >> >> >> There are 2 places to control the voltage. > >> >> >> 1) By setting the AON register calling system-level platform > >> >> >> management > >> >> >layer (SMC) > >> >> >> to set the I/O pads voltage for particular GPIOs line for > >> >> >> clk,data and > >cmd. > >> >> >> The reason why I use this keembay_sd_voltage_selection() via > >> >> >> smccc > >> >> >interface it because during voltage switching > >> >> >> I need to access to AON register. On a secure system, we > >> >> >> could not > >> >> >directly access to AON register due to some security concern from > >> >> >driver side, thus > >> >> >> cannot exposed any register or address. > >> >> >> 2) By controlling the GPIO expander value to drive either 1.8V > >> >> >> or 3.3V for > >> >> >power mux input. > >> >> > > >> >> >I see, thanks for clarifying. > >> >> > > >> >> >To me, it sounds like the best fit is to implement a pinctrl (to > >> >> >manage the I/O > >> >> >pads) and a GPIO regulator. > >> >> > > >> >> Even with pinctrl, i still need to use the > >> >> keembay_sd_voltage_selection() > >> >thingy for AON register. > >> > > >> >Yes, I am fine by that. > >> > > >> >Although, as it's really a pinctrl, it deserves to be modelled like > >> >that. Not as a soc specific hack in a mmc host driver. > >> > > >> >> Plus, the GPIO pin that control the sd-voltage is in GPIO Expander > >> >> not using > >> >Keembay SOC GPIO Pin. > >> >> The best option is using the gpio consumer function to toggle the pin. > >> > > >> >As I said, please no. > >> > > >> >The common way to model this is as a GPIO regulator. In this way, you > >> >can even rely on existing mmc DT bindings. All you have to do is to > >> >hook up a vqmmc supply to the mmc node. > >> > > >> >To be clear, as long as there are no arguments for why a pinctrl and > >> >GPIO regulator can't be used - I am not going to pick up the patches. > >> As I mentioned The SDcard does not have its own voltage regulator. > >> It only uses the voltage rails on the mux input. > >> > >> There are 2 things need to be configured before getting the output voltage: > >> > >> 1) V_VDDIO_B : > >> Supplied voltage applied to I/O Rail which is controlled from the Always on > >domain using specific bits in AON_CFG1 register. > >> This is where we set for V_VDDIO_B using the > >keembay_sd_voltage_selection() to set either 1.8v or 3.3v depending on the > >bit > >value. > >> IMHO, we do not pinctrl to do this. > >> > >> 2) V_VDDIO_B_MAIN: > >> The output V_VDDIO_B_MAIN (OUT1) will be either V_3P3_MAIN (IN1) or > >> V_1P8_MAIN (IN2), depending on the state of GPIO expander Pin value. There > >is a POWER MUX involving here. > >> IMHO, we do not need any gpio regulator/regulator api hook up for this. > >> Most important thing, there is no regulator ic at all. > >> We still need to manually control and toggle the pin value. > >> > >> The final IO voltage is set by V_VDDIO_B (= V_VDDIO_B_MAIN after passing > >through voltage sense resistor). > >> > >> Hope this will clarify. > > > >I think I get it, thanks. > > > >Again, I haven't seen any reasons for why this can't be modelled as a > >pinctrl and > >a gpio-regulator. So, please convert it to that. > For gpio-regulator, I believe I could not use the current gpio-regulator.c > framework as there is no consumer API for me to change the state of gpio pin > during voltage switching.
The consumer API you want to use, is the regulator consumer API, regulator_enable|disable(), for example. Although, as I stated earlier, the mmc core already provides helper functions for this. I suggest you have a look at mmc_regulator_set_vqmmc() and how it's used by other mmc host drivers. > Do I need to create a specific gpio-regulator driver under drivers/regulator > for keem bay? > > I don't think so. Please have a look at Documentation/devicetree/bindings/regulator/gpio-regulator.yaml. This allows you to specify your GPIO regulator in DT. Then from the mmc node you add a "vqmmc-supply" specifier with the phandle to the regulator - that should be it. Kind regards Uffe

