On 14/01/2019 12:57, Marc Gonzalez wrote: > On 13/12/2018 15:24, Marc Gonzalez wrote: > >> I'm having trouble getting UFS working on an APQ8098 MEDIABOX dev board. >> (I'm running v4.20-rc4 with a few UFS patches taken off the MSM list.) >> >> I'm hoping someone with experience with the UFSHC will spot the one thing >> missing that will make everything work! > > Based on Jeffrey's feedback, I looked at voltage regulators again, and > I think there might be an issue in drivers/scsi/ufs/ufshcd.c > > ufshcd_enable_vreg() is supposed to enable a given voltage regulator. > > To do so it calls ufshcd_config_vreg() and then regulator_enable() > > ufshcd_config_vreg() calls regulator_set_voltage() and regulator_set_load() > > However, regulator_set_load() fails if the regulator is not enabled. > > So ufshcd_enable_vreg() fails because the regulator is not enabled... > > Catch 22? The code was introduced 4 years ago, and has never changed. I'm surprised no one ever experienced an issue. Perhaps I have misunderstood... Sujit, as the author of the code, what do you think? Shouldn't we call regulator_enable *before* ufshcd_config_vreg? $ git show --stat aa49761309341 commit aa497613093412ee26ef4bfa4ffec8391553dfca Author: Sujit Reddy Thumma <sthumma@xxxxxxxxxxxxxx> Date: Thu Sep 25 15:32:22 2014 +0300 ufs: Add regulator enable support UFS devices are powered by at most three external power supplies - - VCC - The flash memory core power supply, 2.7V to 3.6V or 1.70V to 1.95V - VCCQ - The controller and I/O power supply, 1.1V to 1.3V - VCCQ2 - Secondary controller and/or I/O power supply, 1.65V to 1.95V For some devices VCCQ or VCCQ2 are optional as they can be generated using internal LDO inside the UFS device. Add DT bindings for voltage regulators that can be controlled from host driver. Signed-off-by: Sujit Reddy Thumma <sthumma@xxxxxxxxxxxxxx> Signed-off-by: Dolev Raviv <draviv@xxxxxxxxxxxxxx> Signed-off-by: Christoph Hellwig <hch@xxxxxx> Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 24 +++++++ drivers/scsi/ufs/ufs.h | 25 +++++++ drivers/scsi/ufs/ufshcd-pltfrm.c | 100 +++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 3 + 5 files changed, 342 insertions(+), 3 deletions(-) Regards.