Re: [PATCH] dts: imx8mq-librem5: Don't wake up on volume key press

2024-06-10 Thread Martin Kepplinger
Am Montag, dem 20.05.2024 um 12:57 +0200 schrieb Guido Günther:
> The only key that should wake up the phone is power button press.
> This
> prevents accidental wakeup due to e.g. pressing the buttons in the
> pocket or backpack and is in line what userspace uses to unblank the
> device.
> 
> Signed-off-by: Guido Günther 

Reviewed-by: Martin Kepplinger 

thank you,

  martin

> ---
>  arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
> b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
> index ffb5fe61630d..1b39514d5c12 100644
> --- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
> +++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
> @@ -45,7 +45,6 @@ key-vol-down {
> gpios = < 17 GPIO_ACTIVE_LOW>;
> linux,code = ;
> debounce-interval = <50>;
> -   wakeup-source;
> };
>  
> key-vol-up {
> @@ -53,7 +52,6 @@ key-vol-up {
> gpios = < 16 GPIO_ACTIVE_LOW>;
> linux,code = ;
> debounce-interval = <50>;
> -   wakeup-source;
> };
> };
>  



Re: [PATCH] Revert "usb: dwc3: gadget: Prevent EP queuing while stopping transfers"

2021-04-02 Thread Martin Kepplinger
Am Donnerstag, dem 01.04.2021 um 11:09 -0700 schrieb Wesley Cheng:
> 
> 
> On 4/1/2021 4:55 AM, Martin Kepplinger wrote:
> > This reverts commit 9de47c3737e0c0207beb03615b320cabe495.
> > 
> > Signed-off-by: Martin Kepplinger 
> > ---
> > 
> > I more or less blindly report:
> > commit 9de47c ("usb: dwc3: gadget: Prevent EP queuing while
> > stopping
> > transfers") results in the below error every time I connect the
> > type-c
> > connector to the dwc3, configured with serial and ethernet gadgets.
> > 
> > fyi, I apply the following to dwc3 on this port:
> > dr_mode =
> > "otg";    
> > snps,dis_u3_susphy_quirk;  
> >  
> > hnp-
> > disable;   
> > srp-
> > disable;   
> > adp-
> > disable;   
> > usb-role-switch;
> > 
> > v5.12-rc5 does not have this error so I'm not sure whether it's
> > more appropriate to add something to dwc3 than reverting. I hope
> > usb
> > people to know better and maybe even see the problem.
> > 
> > thanks,
> >    martin
> > 
> Hi Martin,
> 
> This has been fixed with the below:
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-linus=5aef629704ad4d983ecf5c8a25840f16e45b6d59
> 
> Can you pull that in and give it a try?
> 
> Thanks
> Wesley Cheng

yes, that's a fix for my problem (and what I secretly had hoped to get
:). Thank you very much. In case it helps:

Tested-by: Martin Kepplinger 




[PATCH] Revert "usb: dwc3: gadget: Prevent EP queuing while stopping transfers"

2021-04-01 Thread Martin Kepplinger
This reverts commit 9de47c3737e0c0207beb03615b320cabe495.

Signed-off-by: Martin Kepplinger 
---

I more or less blindly report:
commit 9de47c ("usb: dwc3: gadget: Prevent EP queuing while stopping
transfers") results in the below error every time I connect the type-c
connector to the dwc3, configured with serial and ethernet gadgets.

fyi, I apply the following to dwc3 on this port:
dr_mode = "otg";
snps,dis_u3_susphy_quirk;   
hnp-disable;
srp-disable;
adp-disable;
usb-role-switch;

v5.12-rc5 does not have this error so I'm not sure whether it's
more appropriate to add something to dwc3 than reverting. I hope usb
people to know better and maybe even see the problem.

thanks,
   martin




[   51.148220] [ cut here ]
[   51.148241] dwc3 3810.usb: No resource for ep2in
[   51.148376] WARNING: CPU: 0 PID: 299 at drivers/usb/dwc3/gadget.c:360 
dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148431] Modules linked in: aes_ce_ccm rfcomm algif_hash algif_skcipher 
af_alg bnep qmi_wwan cdc_wdm usbnet mii option usb_wwan usbserial caam_jr 
caamhash_desc caamalg_desc crypto_engine mousedev redpine_sdio redpine_91x 
bluetooth uas usb_storage mac80211 st_lsm6dsx_spi aes_ce_blk crypto_simd 
crct10dif_ce cfg80211 ghash_ce sha2_ce sha1_ce bq25890_charger s5k3l6xx 
snd_soc_wm8962 hi846 vcnl4000 leds_lm3560 edt_ft5x06 ofpart 
industrialio_triggered_buffer tps6598x st_lsm6dsx_i2c st_lsm6dsx kfifo_buf 
gnss_mtk typec mxc_mipi_csi2_yav gnss_serial mx6s_capture gnss 
videobuf2_dma_contig videobuf2_memops spi_nor v4l2_fwnode videobuf2_v4l2 
videobuf2_common snd_soc_gtm601 snd_soc_simple_card videodev mtd 
snd_soc_simple_card_utils mc snd_soc_fsl_sai imx_pcm_dma caam error snvs_pwrkey 
imx_sdma virt_dma snd_soc_core imx2_wdt snd_pcm_dmaengine snd_pcm watchdog 
snd_timer snd soundcore pwm_vibra rfkill_hks rfkill ledtrig_timer usb_f_acm 
u_serial usb_f_rndis g_multi usb_f_mass_storage u_ether
[   51.148759]  libcomposite ledtrig_pattern fuse ip_tables x_tables ipv6 
xhci_plat_hcd xhci_hcd usbcore dwc3 cdns_mhdp_imx ulpi cdns_mhdp_drmcore 
udc_core imx_dcss roles usb_common phy_fsl_imx8mq_usb clk_bd718x7
[   51.148837] CPU: 0 PID: 299 Comm: irq/64-dwc3 Not tainted 
5.11.11-librem5-00334-ge4c4ff3624e9 #218
[   51.148848] Hardware name: Purism Librem 5r4 (DT)
[   51.148854] pstate: 6085 (nZCv daIf -PAN -UAO -TCO BTYPE=--)
[   51.148863] pc : dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148894] lr : dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148924] sp : 800011cb3ac0
[   51.148929] x29: 800011cb3ac0 x28: 032a7b00 
[   51.148942] x27: 0327da00 x26:  
[   51.148954] x25: ffea x24: 0006 
[   51.148967] x23: bee1c080 x22: 800011cb3b7c 
[   51.148979] x21: 0406 x20: bf17 
[   51.148992] x19: 0001 x18:  
[   51.149004] x17:  x16:  
[   51.149016] x15:  x14: 8000114512c0 
[   51.149028] x13: 1698 x12: 0040 
[   51.149040] x11: 80001151a6f8 x10: e000 
[   51.149052] x9 : 8000100b2b7c x8 : 80001146a6f8 
[   51.149065] x7 : 80001151a6f8 x6 :  
[   51.149077] x5 : bf939948 x4 :  
[   51.149089] x3 : 0027 x2 :  
[   51.149101] x1 :  x0 : 049ae040 
[   51.149114] Call trace:
[   51.149120]  dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.149150]  __dwc3_gadget_ep_enable+0x288/0x4fc [dwc3]
[   51.149179]  dwc3_gadget_ep_enable+0x6c/0x15c [dwc3]
[   51.149209]  usb_ep_enable+0x48/0x110 [udc_core]
[   51.149251]  rndis_set_alt+0x138/0x1c0 [usb_f_rndis]
[   51.149276]  composite_setup+0x674/0x194c [libcomposite]
[   51.149314]  dwc3_ep0_interrupt+0x9c4/0xb9c [dwc3]
[   51.149344]  dwc3_thread_interrupt+0x8bc/0xe74 [dwc3]
[   51.149374]  irq_thread_fn+0x38/0xb0
[   51.149388]  irq_thread+0x170/0x294
[   51.149397]  kthread+0x164/0x16c
[   51.149407]  ret_from_fork+0x10/0x34
[   51.149419] ---[ end trace 62c6cc2ebfb18047 ]---
[   51.149436] [ cut here ]
[   51.149440] dwc3 3810.usb: No resource for ep1in
[   51.149507] WARNING: CPU: 0 PID: 299 at drivers/usb/dwc3/gadget.c:360 
dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.149543] Modules linked in: aes_ce_ccm rfcomm algif_hash algif_skcipher 
af_alg bnep qmi_wwan cdc_wdm usbnet mii option usb_wwan usbserial caam_jr 
caamhash_desc caamalg_desc crypto_engine mousedev redpine_sdio redpine_91x 
bluetooth uas usb_storage mac80211 st_lsm6dsx_spi aes_ce_blk crypto_simd 
crct10dif_

[PATCH v2] Revert "usb: dwc3: gadget: Prevent EP queuing while stopping transfers"

2021-04-01 Thread Martin Kepplinger
commit 9de47c ("usb: dwc3: gadget: Prevent EP queuing while stopping
transfers") results in the below error every time I connect the type-c
connector to the dwc3, configured with serial and ethernet gadgets.
I also apply the following to dwc3 on this port:

dr_mode = "otg";
snps,dis_u3_susphy_quirk;   
hnp-disable;
srp-disable;
adp-disable;
usb-role-switch;

[   51.148220] [ cut here ]
[   51.148241] dwc3 3810.usb: No resource for ep2in
[   51.148376] WARNING: CPU: 0 PID: 299 at drivers/usb/dwc3/gadget.c:360 
dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148837] CPU: 0 PID: 299 Comm: irq/64-dwc3 Not tainted 
5.11.11-librem5-00334-ge4c4ff3624e9 #218
[   51.148848] Hardware name: Purism Librem 5r4 (DT)
[   51.148854] pstate: 6085 (nZCv daIf -PAN -UAO -TCO BTYPE=--)
[   51.148863] pc : dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148894] lr : dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.148924] sp : 800011cb3ac0
[   51.148929] x29: 800011cb3ac0 x28: 032a7b00 
[   51.148942] x27: 0327da00 x26:  
[   51.148954] x25: ffea x24: 0006 
[   51.148967] x23: bee1c080 x22: 800011cb3b7c 
[   51.148979] x21: 0406 x20: bf17 
[   51.148992] x19: 0001 x18:  
[   51.149004] x17:  x16:  
[   51.149016] x15:  x14: 8000114512c0 
[   51.149028] x13: 1698 x12: 0040 
[   51.149040] x11: 80001151a6f8 x10: e000 
[   51.149052] x9 : 8000100b2b7c x8 : 80001146a6f8 
[   51.149065] x7 : 80001151a6f8 x6 :  
[   51.149077] x5 : bf939948 x4 :  
[   51.149089] x3 : 0027 x2 :  
[   51.149101] x1 :  x0 : 049ae040 
[   51.149114] Call trace:
[   51.149120]  dwc3_send_gadget_ep_cmd+0x570/0x740 [dwc3]
[   51.149150]  __dwc3_gadget_ep_enable+0x288/0x4fc [dwc3]
[   51.149179]  dwc3_gadget_ep_enable+0x6c/0x15c [dwc3]
[   51.149209]  usb_ep_enable+0x48/0x110 [udc_core]
[   51.149251]  rndis_set_alt+0x138/0x1c0 [usb_f_rndis]
[   51.149276]  composite_setup+0x674/0x194c [libcomposite]
[   51.149314]  dwc3_ep0_interrupt+0x9c4/0xb9c [dwc3]
[   51.149344]  dwc3_thread_interrupt+0x8bc/0xe74 [dwc3]
[   51.149374]  irq_thread_fn+0x38/0xb0
[   51.149388]  irq_thread+0x170/0x294
[   51.149397]  kthread+0x164/0x16c
[   51.149407]  ret_from_fork+0x10/0x34
[   51.149419] ---[ end trace 62c6cc2ebfb18047 ]---

Linus' tree isn't affected. Revert the change.

Signed-off-by: Martin Kepplinger 

---

 drivers/usb/dwc3/gadget.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 2a86ad4b12b3..ef8ecaf8655a 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -783,6 +783,8 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
 
trace_dwc3_gadget_ep_disable(dep);
 
+   dwc3_remove_requests(dwc, dep);
+
/* make sure HW endpoint isn't stalled */
if (dep->flags & DWC3_EP_STALL)
__dwc3_gadget_ep_set_halt(dep, 0, false);
@@ -801,8 +803,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
dep->endpoint.desc = NULL;
}
 
-   dwc3_remove_requests(dwc, dep);
-
return 0;
 }
 
@@ -1617,7 +1617,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, 
struct dwc3_request *req)
 {
struct dwc3 *dwc = dep->dwc;
 
-   if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) {
+   if (!dep->endpoint.desc || !dwc->pullups_connected) {
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
dep->name);
return -ESHUTDOWN;
@@ -2150,7 +2150,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int 
is_on)
if (!is_on) {
u32 count;
 
-   dwc->connected = false;
/*
 * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a
 * Section 4.1.8 Table 4-7, it states that for a 
device-initiated
@@ -2175,6 +2174,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int 
is_on)
dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
dwc->ev_buf->length;
}
+   dwc->connected = false;
} else {
__dwc3_gadget_start(dwc);
}
@@ -3267,6 +3267,8 @@ static v

Re: [PATCH v3 1/4] scsi: add expecting_media_change flag to error path

2021-03-29 Thread Martin Kepplinger
Am Sonntag, dem 28.03.2021 um 09:53 -0700 schrieb Bart Van Assche:
> On 3/28/21 3:25 AM, Martin Kepplinger wrote:
> > diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> > index 08c06c56331c..c62915d34ba4 100644
> > --- a/drivers/scsi/scsi_error.c
> > +++ b/drivers/scsi/scsi_error.c
> > @@ -585,6 +585,18 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
> > return NEEDS_RETRY;
> > }
> > }
> > +   if (scmd->device->expecting_media_change) {
> > +   if (sshdr.asc == 0x28 && sshdr.ascq ==
> > 0x00) {
> > +   /*
> > +    * clear the expecting_media_change
> > in
> > +    * scsi_decide_disposition()
> > because we
> > +    * need to catch possible "fail
> > fast" overrides
> > +    * that block readahead can cause.
> > +    */
> > +   return NEEDS_RETRY;
> > +   }
> > +   }
> 
> Introducing a new state variable carries some risk, namely that a
> path
> that should set or clear the state variable is overlooked. Is there
> an
> approach that does not require to introduce a new state variable,
> e.g.
> to send a REQUEST SENSE command after a resume?
> 
> Thanks,
> 
> Bart.

wow, thanks for that. Indeed my first tests succeed with the below
change, that doesn't use the error-path additions at all (not setting
expecting_media_change), and sends a request sense instead.

I'm just too little of a scsi developer that I know whether the below
change correctly does what you had in mind. Does it?


--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3707,6 +3707,10 @@ static int sd_resume_runtime(struct device *dev)
 {
struct scsi_disk *sdkp = dev_get_drvdata(dev);
struct scsi_device *sdp = sdkp->device;
+   const int timeout = sdp->request_queue->rq_timeout
+   * SD_FLUSH_TIMEOUT_MULTIPLIER;
+   int retries, res;
+   struct scsi_sense_hdr my_sshdr;
int ret;
 
if (!sdkp)  /* E.g.: runtime resume at the start of
sd_probe() */
@@ -3714,10 +3718,25 @@ static int sd_resume_runtime(struct device
*dev)
 
/*
 * This devices issues a MEDIA CHANGE unit attention when
-* resuming from suspend. Ignore the next one now.
+* resuming from suspend.
 */
-   if (sdp->sdev_bflags & BLIST_MEDIA_CHANGE)
-   sdkp->device->expecting_media_change = 1;
+   if (sdp->sdev_bflags & BLIST_MEDIA_CHANGE) {
+   for (retries = 3; retries > 0; --retries) {
+   unsigned char cmd[10] = { 0 };
+
+   cmd[0] = REQUEST_SENSE;
+   /*
+* Leave the rest of the command zero to
indicate
+* flush everything.
+*/
+   res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0,
NULL, _sshdr,
+   timeout, sdkp->max_retries, 0,
RQF_PM, NULL);
+   if (res == 0)
+   break;
+   }
+   }
 
return sd_resume(dev);



Re: [PATCH v3 0/4] scsi: add runtime PM workaround for SD cardreaders

2021-03-28 Thread Martin Kepplinger
Am Sonntag, dem 28.03.2021 um 10:58 -0400 schrieb Alan Stern:
> On Sun, Mar 28, 2021 at 12:25:27PM +0200, Martin Kepplinger wrote:
> > hi,
> > 
> > In short: there are SD cardreaders that send MEDIA_CHANGED on
> > (runtime) resume. We cannot use runtime PM with these devices as
> > I/O always fails. I'd like to discuss a way to fix this
> > or at least allow us to work around this problem:
> 
> In fact, as far as I know _all_ USB SD card readers send Media
> Changed 
> notifications on resume.  Maybe there are some that don't, but I
> haven't 
> heard of any.
> 
> Alan Stern

that makes me worry less about enabling this for "Generic", "Ultra HS-
SD/MMC" then. thanks.

it also makes me think about whether sd should implement this even for
system-resume (not only runtime resume), but I guess that's a minor
issue we could add at any time later.

   martin




[PATCH v3 3/4] scsi: sd: use expecting_media_change for BLIST_MEDIA_CHANGE devices

2021-03-28 Thread Martin Kepplinger
For SD cardreader devices that have the BLIST_MEDIA_CHANGE flag set,
ignore one MEDIA CHANGE unit attention after resuming from runtime
suspend. These devices issue said unit attention when resuming
even when no medium changed.

expecting_media_change is the device flag that is being clearing in
the error path.

The "downside" is that for these devices we now rely on users not to
really change the medium (SD card) *during* a runtime suspend/resume
cycle, i.e. when not unmounting.

Since these devices don't distinguish between resume and medium changed
there's no better solution.

To enable runtime PM for an SD cardreader (device number 0:0:0:0), do:

echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/sd.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 91c34ee972c7..0a6413a4c629 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -63,6 +63,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -114,6 +115,7 @@ static void sd_shutdown(struct device *);
 static int sd_suspend_system(struct device *);
 static int sd_suspend_runtime(struct device *);
 static int sd_resume(struct device *);
+static int sd_resume_runtime(struct device *);
 static void sd_rescan(struct device *);
 static blk_status_t sd_init_command(struct scsi_cmnd *SCpnt);
 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
@@ -608,7 +610,7 @@ static const struct dev_pm_ops sd_pm_ops = {
.poweroff   = sd_suspend_system,
.restore= sd_resume,
.runtime_suspend= sd_suspend_runtime,
-   .runtime_resume = sd_resume,
+   .runtime_resume = sd_resume_runtime,
 };
 
 static struct scsi_driver sd_template = {
@@ -3701,6 +3703,25 @@ static int sd_resume(struct device *dev)
return ret;
 }
 
+static int sd_resume_runtime(struct device *dev)
+{
+   struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   struct scsi_device *sdp = sdkp->device;
+   int ret;
+
+   if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
+   return 0;
+
+   /*
+* This device issues a MEDIA CHANGE unit attention when
+* resuming from suspend. Ignore the next one from now.
+*/
+   if (sdp->sdev_bflags & BLIST_MEDIA_CHANGE)
+   sdkp->device->expecting_media_change = 1;
+
+   return sd_resume(dev);
+}
+
 /**
  * init_sd - entry point for this driver (both when built in or when
  * a module).
-- 
2.30.2



[PATCH v3 1/4] scsi: add expecting_media_change flag to error path

2021-03-28 Thread Martin Kepplinger
SD Cardreaders (especially) sometimes lose the state during suspend
and deliver a "media changed" unit attention when really only a
(runtime) suspend/resume cycle has been done.

For such devices, I/O fails when runtime PM is enabled, see below.
That's the motivation to add this flag. If set by a driver the
one following MEDIA CHANGE unit attention will be ignored.

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_error.c  | 36 +++-
 include/scsi/scsi_device.h |  1 +
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 08c06c56331c..c62915d34ba4 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -585,6 +585,18 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
return NEEDS_RETRY;
}
}
+   if (scmd->device->expecting_media_change) {
+   if (sshdr.asc == 0x28 && sshdr.ascq == 0x00) {
+   /*
+* clear the expecting_media_change in
+* scsi_decide_disposition() because we
+* need to catch possible "fail fast" overrides
+* that block readahead can cause.
+*/
+   return NEEDS_RETRY;
+   }
+   }
+
/*
 * we might also expect a cc/ua if another LUN on the target
 * reported a UA with an ASC/ASCQ of 3F 0E -
@@ -1977,14 +1989,28 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 * the request was not marked fast fail.  Note that above,
 * even if the request is marked fast fail, we still requeue
 * for queue congestion conditions (QUEUE_FULL or BUSY) */
-   if (scsi_cmd_retry_allowed(scmd) && !scsi_noretry_cmd(scmd)) {
-   return NEEDS_RETRY;
-   } else {
-   /*
-* no more retries - report this one back to upper level.
+   if (scsi_cmd_retry_allowed(scmd)) {
+   /* but scsi_noretry_cmd() cannot override the
+* expecting_media_change flag.
 */
+   if (!scsi_noretry_cmd(scmd) ||
+   scmd->device->expecting_media_change) {
+   scmd->device->expecting_media_change = 0;
+   return NEEDS_RETRY;
+   }
+
+   /* Not marked fail fast, or marked but not expected.
+* Clear the flag too because it's meant for the
+* next UA only.
+*/
+   scmd->device->expecting_media_change = 0;
return SUCCESS;
}
+
+   /*
+* no more retries - report this one back to upper level.
+*/
+   return SUCCESS;
 }
 
 static void eh_lock_door_done(struct request *req, blk_status_t status)
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 05c7c320ef32..926b42ce1dc4 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -171,6 +171,7 @@ struct scsi_device {
 * this device */
unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
 * because we did a bus reset. */
+   unsigned expecting_media_change:1; /* Expecting "media changed" UA */
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */
-- 
2.30.2



[PATCH v3 2/4] scsi: devinfo: add new flag BLIST_MEDIA_CHANGE

2021-03-28 Thread Martin Kepplinger
add a new flag for devices that issue MEDIA CHANGE unit attentions
when actually no medium changed. Drivers can for example set the
expecting_media_change device flag in order to ignore the next
following MEDIA CHANGE unit attention.

Signed-off-by: Martin Kepplinger 
---
 include/scsi/scsi_devinfo.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 3fdb322d4c4b..dee9dce14887 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -28,7 +28,8 @@
 #define BLIST_LARGELUN ((__force blist_flags_t)(1ULL << 9))
 /* override additional length field */
 #define BLIST_INQUIRY_36   ((__force blist_flags_t)(1ULL << 10))
-#define __BLIST_UNUSED_11  ((__force blist_flags_t)(1ULL << 11))
+/* Ignore the next media change event */
+#define BLIST_MEDIA_CHANGE ((__force blist_flags_t)(1ULL << 11))
 /* do not do automatic start on add */
 #define BLIST_NOSTARTONADD ((__force blist_flags_t)(1ULL << 12))
 #define __BLIST_UNUSED_13  ((__force blist_flags_t)(1ULL << 13))
@@ -73,8 +74,7 @@
 #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
   (__force blist_flags_t) \
   ((__force __u64)__BLIST_LAST_USED - 1ULL)))
-#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_11 | \
-__BLIST_UNUSED_13 | \
+#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_13 | \
 __BLIST_UNUSED_14 | \
 __BLIST_UNUSED_15 | \
 __BLIST_UNUSED_16 | \
-- 
2.30.2



[PATCH v3 4/4] scsi: devinfo: add BLIST_MEDIA_CHANGE for Ultra HS-SD/MMC usb cardreaders

2021-03-28 Thread Martin Kepplinger
This cardreader device issues a MEDIA CHANGE unit attention not only
when actually a medium changed but also simply when resuming from suspend.
(probably because the device can't know what happens during suspend and
want to say "medium could have changed").

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_devinfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index d92cec12454c..7d6446f81908 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -171,6 +171,7 @@ static struct {
{"FUJITSU", "ETERNUS_DXM", "*", BLIST_RETRY_ASC_C1},
{"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36},
{"Generic", "USB Storage-SMC", NULL, BLIST_FORCELUN | 
BLIST_INQUIRY_36}, /* FW: 0180 and 0207 */
+   {"Generic", "Ultra HS-SD/MMC", "2.09", BLIST_MEDIA_CHANGE | 
BLIST_INQUIRY_36},
{"HITACHI", "DF400", "*", BLIST_REPORTLUN2},
{"HITACHI", "DF500", "*", BLIST_REPORTLUN2},
{"HITACHI", "DISK-SUBSYSTEM", "*", BLIST_REPORTLUN2},
-- 
2.30.2



[PATCH v3 0/4] scsi: add runtime PM workaround for SD cardreaders

2021-03-28 Thread Martin Kepplinger
hi,

In short: there are SD cardreaders that send MEDIA_CHANGED on
(runtime) resume. We cannot use runtime PM with these devices as
I/O always fails. I'd like to discuss a way to fix this
or at least allow us to work around this problem:

For the full background, the discussion started in June 2020 here:
https://lore.kernel.org/linux-scsi/20200623111018.31954-1-martin.kepplin...@puri.sm/

I'd appreciate any feedback.

Especially: Any naming-preferences for the flags? And is the specific
device that I need this workaround for (Generic Ultra HS-SD/MMC, connected
via USB) too "generic" maybe? Not sure about what possibilities I'd have here...


revision history

v3: (thank you Bart)
 * create a new BLIST entry to mark affected devices instead of the
   sysfs module parameter for sd only. still, only sd implements handling
   the flag for now.
 * cc linux-pm list

v2:
https://lore.kernel.org/linux-scsi/20210112093329.3639-1-martin.kepplin...@puri.sm/
 * move module parameter to sd
 * add Documentation
v1:
https://lore.kernel.org/linux-scsi/2021052029.28426-1-martin.kepplin...@puri.sm/T/


Martin Kepplinger (4):
  scsi: add expecting_media_change flag to error path
  scsi: devinfo: add new flag BLIST_MEDIA_CHANGE
  scsi: sd: use expecting_media_change for BLIST_MEDIA_CHANGE devices
  scsi: devinfo: add BLIST_MEDIA_CHANGE for Ultra HS-SD/MMC usb
cardreaders

 drivers/scsi/scsi_devinfo.c |  1 +
 drivers/scsi/scsi_error.c   | 36 +++-
 drivers/scsi/sd.c   | 23 ++-
 include/scsi/scsi_device.h  |  1 +
 include/scsi/scsi_devinfo.h |  6 +++---
 5 files changed, 58 insertions(+), 9 deletions(-)

-- 
2.30.2



Re: [PATCH v2 0/3] scsi: add runtime PM workaround for SD cardreaders

2021-03-27 Thread Martin Kepplinger
Am Dienstag, dem 12.01.2021 um 10:33 +0100 schrieb Martin Kepplinger:
> revision history
> 
> v2:
>  * move module parameter to sd
>  * add Documentation
> 
> v1:
> https://lore.kernel.org/linux-scsi/2021052029.28426-1-martin.kepplin...@puri.sm/T/#t
> 
> 
> 
> hi,
> 
> In short: there are SD cardreaders that send MEDIA_CHANGED on
> runtime resume. We cannot use runtime PM with these devices as
> I/O basically always fails. I'd like to discuss a way to fix this
> or at least allow users to work around this problem:
> 
> For the full background, the discussion started in June 2020 here:
> https://lore.kernel.org/linux-scsi/20200623111018.31954-1-martin.kepplin...@puri.sm/
> 
> and I sent the first of these patches in August, as a reference:
> https://lore.kernel.org/linux-scsi/20200824190400.12339-1-martin.kepplin...@puri.sm/
> so this is where I'm following up on.
> 
> I'm not sure whether maintaining an in-kernel quirk for specific
> devices
> makes sense so here I suggest adding a userspace knob. This way
> there's at
> least a chance to use runtime PM for sd cardreaders that send
> MEDIA_CHANGED.
> 
> I'd appreciate any feedback.
> 
> Martin Kepplinger (3):
>   scsi: add expecting_media_change flag to error path
>   scsi: sd: add ignore_resume_medium_changed disk setting
>   scsi: sd: Documentation: describe ignore_resume_medium_changed
> 
>  Documentation/scsi/sd-parameters.rst | 14 
>  drivers/scsi/scsi_error.c    | 36 +---
>  drivers/scsi/sd.c    | 50
> +++-
>  drivers/scsi/sd.h    |  1 +
>  include/scsi/scsi_device.h   |  1 +
>  5 files changed, 96 insertions(+), 6 deletions(-)
> 

hi James, Bart and all,

since this is absolutely needed for runtime pm with the SD device we
use I assume there are others that would benefit from this too. Do you
have any concerns or thoughts about this (logic and interface)?

the patches still apply.

thanks a lot,

 martin




Re: [RFC 00/19] Rework support for i.MX8MQ interconnect with devfreq

2021-03-24 Thread Martin Kepplinger
Am Dienstag, dem 09.03.2021 um 13:43 +0200 schrieb Abel Vesa:
> On 21-02-25 13:13:17, Martin Kepplinger wrote:
> > On 23.02.21 18:20, Abel Vesa wrote:
> > > On 21-02-22 17:03:13, Martin Kepplinger wrote:
> > > > On 19.02.21 16:59, Abel Vesa wrote:
> > > > > This has been on my queue for quite some time now. It is more
> > > > > of a
> > > > > proof-of-concept.
> > > > > 
> > > > > This rework is done with the compatibility of future i.MX
> > > > > platforms in
> > > > > mind. For example, the i.MX8MP platform has multiple NoCs.
> > > > > This
> > > > > patchsets prepares the imx interconnect and imx devfreq for
> > > > > that too.
> > > > > 
> > > > > As of now, none of the drivers involved are being used and
> > > > > there is no
> > > > > icc consumer on any off the i.MX platforms.
> > > > > 
> > > > > Basically, the steps taken here are the following:
> > > > > 
> > > > > 1. Make the dram_apb clock "reparantable" from kernel.
> > > > > This is needed in order to keep track of the actual parent of
> > > > > the
> > > > > dram_apb clock in the kernel clock hierarchy. Note that the
> > > > > actual
> > > > > switch is done EL3 (TF-A).
> > > > > 
> > > > > 2. Rework the imx-bus so the actual link between the icc and
> > > > > the
> > > > > NoCs or the pl301s is not tightly coupled. This allows us to
> > > > > have
> > > > > as many NoCs as necessary but also allows as to use the same
> > > > > driver
> > > > > for the pl301s. The pl301s have their own clocks too, so we
> > > > > need to
> > > > > reduce their rates too.
> > > > > 
> > > > > 3. Rework the imx8m-ddrc driver. Remove the support for dts
> > > > > defined
> > > > > OPPs. The EL3 provides those. So instead of havingi to keep
> > > > > the OPP table in
> > > > > both EL3 and kernel in sync, we rely on what the EL3 gives
> > > > > us.
> > > > > Also, when the platform suspends, the bus needs to be running
> > > > > at highest
> > > > > rate, otherwise there is a chance it might not resume
> > > > > anymore.
> > > > > By adding the late system sleep PM ops we can handle that
> > > > > easily.
> > > > > 
> > > > > 4. Rework the imx interconnect driver to use the fsl,icc-id
> > > > > instead
> > > > > of the robust imx_icc_node_adj_desc for linking with the
> > > > > target node.
> > > > > By adding the fsl,icc-id property to all the NoC and pl301
> > > > > dts nodes,
> > > > > we can link each icc node to their corresponding NoC, pl301
> > > > > or dram.
> > > > > Basically, when the imx interconnect platform specific driver
> > > > > probes,
> > > > > it will take each node defined for that platform and look-up
> > > > > the
> > > > > corresponding dts node based on the id and add that as the
> > > > > qos device.
> > > > > 
> > > > > 5. Added the fec and usdhc as icc consumers. This is just as
> > > > > an example.
> > > > > All the other consumers can be added later. Basically, each
> > > > > consumer
> > > > > will add a path to their device node and in the driver will
> > > > > have to
> > > > > handle that icc path accordingly.
> > > > > 
> > > > 
> > > > thanks for working on this Abel,
> > > > 
> > > > It looks like the icc path requests don't work for me:
> > > > 
> > > > when applying this onto v5.11 (without any other workaround in
> > > > that area,
> > > > but some out-of-tree icc-requests like in mxsfb) my rootfs
> > > > isn't being
> > > > mounted anymore. Since you add icc requests to the usdhc
> > > > driver, there could
> > > > be something wrong.
> > > > 
> > > > So I revert 19/19 ("mmc: sdhci-esdhc-imx: Add interconnect
> > > > support") and
> > > > then my imx8mq (Librem 5) rootfs system boots, but all
> > > > frequencies stay at
> > >

[PATCH v2 3/3] arm64: defconfig: Enable the Hantro decoder

2021-03-15 Thread Martin Kepplinger
From: Fabio Estevam 

Enable the Hantro decoder driver so it can be enabled by
default on i.MX8M and Rockchip platforms.

Signed-off-by: Fabio Estevam 
Reviewed-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 1f673b00c5f5..1a5669a73c01 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -919,6 +919,9 @@ CONFIG_VIRTIO_MMIO=y
 CONFIG_XEN_GNTDEV=y
 CONFIG_XEN_GRANT_DEV_ALLOC=y
 CONFIG_MFD_CROS_EC_DEV=y
+CONFIG_STAGING=y
+CONFIG_STAGING_MEDIA=y
+CONFIG_VIDEO_HANTRO=m
 CONFIG_CHROME_PLATFORMS=y
 CONFIG_CROS_EC=y
 CONFIG_CROS_EC_I2C=y
-- 
2.30.1



[PATCH v2 2/3] arm64: dts: imx8mq-librem5-r3: Mark buck3 as always on

2021-03-15 Thread Martin Kepplinger
From: Sebastian Krzyszkowiak 

Commit 99e71c029213 ("arm64: dts: imx8mq-librem5: Don't mark buck3 as always 
on")
removed always-on marking from GPU regulator, which is great for power
saving - however it introduces additional i2c0 traffic which can be deadly
for devices from the Dogwood batch.

To workaround the i2c0 shutdown issue on Dogwood, this commit marks
buck3 as always-on again - but only for Dogwood (r3).

Signed-off-by: Sebastian Krzyszkowiak 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
index 0d38327043f8..cd3c3edd48fa 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
@@ -28,6 +28,10 @@  {
ti,termination-current = <144000>;  /* uA */
 };
 
+_reg {
+   regulator-always-on;
+};
+
  {
proximity-near-level = <25>;
 };
-- 
2.30.1



[PATCH v2 1/3] arm64: dts: imx8mq-librem5: Hog the correct gpio

2021-03-15 Thread Martin Kepplinger
From: Guido Günther 

There was an additional alias in the specifier it hogged line 27
instead of line 1.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 2d248304432b..460ef0d86540 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -286,8 +286,9 @@  {
 
pmic-5v-hog {
gpio-hog;
-   gpios = < 1 GPIO_ACTIVE_HIGH>;
+   gpios = <1 GPIO_ACTIVE_HIGH>;
input;
+   lane-mapping = "pmic-5v";
};
 };
 
-- 
2.30.1



[PATCH v2 0/3] Librem 5 phone dts fixes

2021-03-15 Thread Martin Kepplinger
Two fixes for the Librem 5 phone descriptions and one resend of
https://lore.kernel.org/linux-arm-kernel/20200915141622.14736-1-feste...@gmail.com/
that enables the hantro vpu staging driver. Feel free to ignore that one
if we want to wait for it to be out of staging.

revision history

v2: (thanks Shawn)
 * fix commit hash in commit message

v1:
 * 
https://lore.kernel.org/phone-devel/20210311120259.3310499-1-martin.kepplin...@puri.sm/T/

Fabio Estevam (1):
  arm64: defconfig: Enable the Hantro decoder

Guido Günther (1):
  arm64: dts: imx8mq-librem5: Hog the correct gpio

Sebastian Krzyszkowiak (1):
  arm64: dts: imx8mq-librem5-r3: Mark buck3 as always on

 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 4 
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi   | 3 ++-
 arch/arm64/configs/defconfig| 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.30.1



[PATCH 3/3] arm64: defconfig: Enable the Hantro decoder

2021-03-11 Thread Martin Kepplinger
From: Fabio Estevam 

Enable the Hantro decoder driver so it can be enabled by
default on i.MX8M and Rockchip platforms.

Signed-off-by: Fabio Estevam 
Reviewed-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 1f673b00c5f5..1a5669a73c01 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -919,6 +919,9 @@ CONFIG_VIRTIO_MMIO=y
 CONFIG_XEN_GNTDEV=y
 CONFIG_XEN_GRANT_DEV_ALLOC=y
 CONFIG_MFD_CROS_EC_DEV=y
+CONFIG_STAGING=y
+CONFIG_STAGING_MEDIA=y
+CONFIG_VIDEO_HANTRO=m
 CONFIG_CHROME_PLATFORMS=y
 CONFIG_CROS_EC=y
 CONFIG_CROS_EC_I2C=y
-- 
2.30.1



[PATCH 0/3] Librem 5 phone dts fixes

2021-03-11 Thread Martin Kepplinger
Two fixes for the Librem 5 phone descriptions and one resend of
https://lore.kernel.org/linux-arm-kernel/20200915141622.14736-1-feste...@gmail.com/
that enables the hantro vpu staging driver. Feel free to ignore that one
if we want to wait for it to be out of staging.

Fabio Estevam (1):
  arm64: defconfig: Enable the Hantro decoder

Guido Günther (1):
  arm64: dts: imx8mq-librem5: Hog the correct gpio

Sebastian Krzyszkowiak (1):
  arm64: dts: imx8mq-librem5-r3: Mark buck3 as always on

 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 4 
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi   | 3 ++-
 arch/arm64/configs/defconfig| 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.30.1



[PATCH 2/3] arm64: dts: imx8mq-librem5-r3: Mark buck3 as always on

2021-03-11 Thread Martin Kepplinger
From: Sebastian Krzyszkowiak 

Commit 66d3f246d79f ("arm64: dts: librem5: Don't mark buck3 as always on")
removed always-on marking from GPU regulator, which is great for power
saving - however it introduces additional i2c0 traffic which can be deadly
for devices from the Dogwood batch.

To workaround the i2c0 shutdown issue on Dogwood, this commit marks
buck3 as always-on again - but only for Dogwood (r3).

Signed-off-by: Sebastian Krzyszkowiak 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
index 0d38327043f8..cd3c3edd48fa 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
@@ -28,6 +28,10 @@  {
ti,termination-current = <144000>;  /* uA */
 };
 
+_reg {
+   regulator-always-on;
+};
+
  {
proximity-near-level = <25>;
 };
-- 
2.30.1



[PATCH 1/3] arm64: dts: imx8mq-librem5: Hog the correct gpio

2021-03-11 Thread Martin Kepplinger
From: Guido Günther 

There was an additional alias in the specifier it hogged line 27
instead of line 1.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 2d248304432b..460ef0d86540 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -286,8 +286,9 @@  {
 
pmic-5v-hog {
gpio-hog;
-   gpios = < 1 GPIO_ACTIVE_HIGH>;
+   gpios = <1 GPIO_ACTIVE_HIGH>;
input;
+   lane-mapping = "pmic-5v";
};
 };
 
-- 
2.30.1



[PATCH] arm64: dts: imx8mq: remove SoC ID compatible

2021-03-09 Thread Martin Kepplinger
this reverts commit ce58459d8c7f4174e7b8a8ea903dd949631334a3 for imx8mq.

this is most likely not the real fix but works around the problem I have
(with v5.12-rc2) I want to report:

[0.766925] SoC revision 0x21
[0.770286] imx8_soc_info soc@0: SoC revision via nvmem read failed: -517

This leads to the system not booting up.

This change makes use of the old way of reading soc_revision and thus
works around the problem.

What could be missing for the nvmem way to work here? Should it work
in any case? I assume so if you add the compatible to imx8mq.dtsi. But
if it would work, why keep the ocotp reads?

thanks a lot,
 martin


---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index e1ca17fc1fa1..b40f7081e825 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -287,7 +287,7 @@ timer {
};
 
soc@0 {
-   compatible = "fsl,imx8mq-soc", "simple-bus";
+   compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x0 0x0 0x0 0x3e00>;
-- 
2.30.1



[PATCH] Documentation: dynamic-debug-howto: fix example

2021-03-03 Thread Martin Kepplinger
dynamic debug is "expecting pairs of match-spec " so the example
for all files of which the paths include "usb" there is "file" missing.

Signed-off-by: Martin Kepplinger 
---
 Documentation/admin-guide/dynamic-debug-howto.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst 
b/Documentation/admin-guide/dynamic-debug-howto.rst
index 6c04aea8f4cd..b119b8277b3e 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -347,7 +347,7 @@ Examples
/dynamic_debug/control
 
   // enable messages in files of which the paths include string "usb"
-  nullarbor:~ # echo -n '*usb* +p' > /dynamic_debug/control
+  nullarbor:~ # echo -n 'file *usb* +p' > /dynamic_debug/control
 
   // enable all messages
   nullarbor:~ # echo -n '+p' > /dynamic_debug/control
-- 
2.30.1



Re: [RFC 00/19] Rework support for i.MX8MQ interconnect with devfreq

2021-02-25 Thread Martin Kepplinger

On 23.02.21 18:20, Abel Vesa wrote:

On 21-02-22 17:03:13, Martin Kepplinger wrote:

On 19.02.21 16:59, Abel Vesa wrote:

This has been on my queue for quite some time now. It is more of a
proof-of-concept.

This rework is done with the compatibility of future i.MX platforms in
mind. For example, the i.MX8MP platform has multiple NoCs. This
patchsets prepares the imx interconnect and imx devfreq for that too.

As of now, none of the drivers involved are being used and there is no
icc consumer on any off the i.MX platforms.

Basically, the steps taken here are the following:

1. Make the dram_apb clock "reparantable" from kernel.
This is needed in order to keep track of the actual parent of the
dram_apb clock in the kernel clock hierarchy. Note that the actual
switch is done EL3 (TF-A).

2. Rework the imx-bus so the actual link between the icc and the
NoCs or the pl301s is not tightly coupled. This allows us to have
as many NoCs as necessary but also allows as to use the same driver
for the pl301s. The pl301s have their own clocks too, so we need to
reduce their rates too.

3. Rework the imx8m-ddrc driver. Remove the support for dts defined
OPPs. The EL3 provides those. So instead of havingi to keep the OPP table in
both EL3 and kernel in sync, we rely on what the EL3 gives us.
Also, when the platform suspends, the bus needs to be running at highest
rate, otherwise there is a chance it might not resume anymore.
By adding the late system sleep PM ops we can handle that easily.

4. Rework the imx interconnect driver to use the fsl,icc-id instead
of the robust imx_icc_node_adj_desc for linking with the target node.
By adding the fsl,icc-id property to all the NoC and pl301 dts nodes,
we can link each icc node to their corresponding NoC, pl301 or dram.
Basically, when the imx interconnect platform specific driver probes,
it will take each node defined for that platform and look-up the
corresponding dts node based on the id and add that as the qos device.

5. Added the fec and usdhc as icc consumers. This is just as an example.
All the other consumers can be added later. Basically, each consumer
will add a path to their device node and in the driver will have to
handle that icc path accordingly.



thanks for working on this Abel,

It looks like the icc path requests don't work for me:

when applying this onto v5.11 (without any other workaround in that area,
but some out-of-tree icc-requests like in mxsfb) my rootfs isn't being
mounted anymore. Since you add icc requests to the usdhc driver, there could
be something wrong.

So I revert 19/19 ("mmc: sdhci-esdhc-imx: Add interconnect support") and
then my imx8mq (Librem 5) rootfs system boots, but all frequencies stay at
the minimum (despite the icc request like this:
https://source.puri.sm/martin.kepplinger/linux-next/-/commit/1692de27d1475c53574dd7359c68ba613e0fea10
so I can't use the display).

What could be missing? As I said I'm trying on top of v5.11, (at least I
have the NOC node described:
https://source.puri.sm/martin.kepplinger/linux-next/-/commit/1d74a24c9944d1bf618abdd57d24101368cc8df0
and (with the revert from
https://lore.kernel.org/linux-arm-kernel/20210104120512.gmi2zjz7dzhjussp@fsr-ub1664-175/
devfreq works without your patchset ) Is there anything I'm missing that is
not yet merged in v5.11?

Can I test anything else that would help?



Sorry about this, I messed up the usdhc change.
I tested mostly with nfs rootfs.

I'll just paste here the things that are missing in order for the USHCs to work.
I'll fold them in the next version of this patch set.

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 43760316052f..90398408b55e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1637,6 +1637,25 @@ opp-133M {
 };
 };
  
+   pl301_per_m: pl301@9 {

+   compatible = "fsl,imx8m-nic";
+   clocks = < IMX8MQ_CLK_NAND_USDHC_BUS>;
+   operating-points-v2 = <_per_m_opp_table>;
+   #interconnect-cells = <0>;
+   fsl,icc-id = ;
+
+   pl301_per_m_opp_table: opp-table {
+   compatible = "operating-points-v2";
+
+   opp-25M {
+   opp-hz = /bits/ 64 <2500>;
+   };
+   opp-133M {
+   opp-hz = /bits/ 64 <1>;
+   };
+   };
+   };
+
 icc: interconnect@0 {
 compatible = "fsl,imx8mq-icc", "fsl,imx8m-icc";
 #interconnect-cells = <1>;
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c

Re: [RFC 00/19] Rework support for i.MX8MQ interconnect with devfreq

2021-02-22 Thread Martin Kepplinger

On 19.02.21 16:59, Abel Vesa wrote:

This has been on my queue for quite some time now. It is more of a
proof-of-concept.

This rework is done with the compatibility of future i.MX platforms in
mind. For example, the i.MX8MP platform has multiple NoCs. This
patchsets prepares the imx interconnect and imx devfreq for that too.

As of now, none of the drivers involved are being used and there is no
icc consumer on any off the i.MX platforms.

Basically, the steps taken here are the following:

1. Make the dram_apb clock "reparantable" from kernel.
This is needed in order to keep track of the actual parent of the
dram_apb clock in the kernel clock hierarchy. Note that the actual
switch is done EL3 (TF-A).

2. Rework the imx-bus so the actual link between the icc and the
NoCs or the pl301s is not tightly coupled. This allows us to have
as many NoCs as necessary but also allows as to use the same driver
for the pl301s. The pl301s have their own clocks too, so we need to
reduce their rates too.

3. Rework the imx8m-ddrc driver. Remove the support for dts defined
OPPs. The EL3 provides those. So instead of havingi to keep the OPP table in
both EL3 and kernel in sync, we rely on what the EL3 gives us.
Also, when the platform suspends, the bus needs to be running at highest
rate, otherwise there is a chance it might not resume anymore.
By adding the late system sleep PM ops we can handle that easily.

4. Rework the imx interconnect driver to use the fsl,icc-id instead
of the robust imx_icc_node_adj_desc for linking with the target node.
By adding the fsl,icc-id property to all the NoC and pl301 dts nodes,
we can link each icc node to their corresponding NoC, pl301 or dram.
Basically, when the imx interconnect platform specific driver probes,
it will take each node defined for that platform and look-up the
corresponding dts node based on the id and add that as the qos device.

5. Added the fec and usdhc as icc consumers. This is just as an example.
All the other consumers can be added later. Basically, each consumer
will add a path to their device node and in the driver will have to
handle that icc path accordingly.



thanks for working on this Abel,

It looks like the icc path requests don't work for me:

when applying this onto v5.11 (without any other workaround in that 
area, but some out-of-tree icc-requests like in mxsfb) my rootfs isn't 
being mounted anymore. Since you add icc requests to the usdhc driver, 
there could be something wrong.


So I revert 19/19 ("mmc: sdhci-esdhc-imx: Add interconnect support") and 
then my imx8mq (Librem 5) rootfs system boots, but all frequencies stay 
at the minimum (despite the icc request like this: 
https://source.puri.sm/martin.kepplinger/linux-next/-/commit/1692de27d1475c53574dd7359c68ba613e0fea10 
so I can't use the display).


What could be missing? As I said I'm trying on top of v5.11, (at least I 
have the NOC node described: 
https://source.puri.sm/martin.kepplinger/linux-next/-/commit/1d74a24c9944d1bf618abdd57d24101368cc8df0 
and (with the revert from 
https://lore.kernel.org/linux-arm-kernel/20210104120512.gmi2zjz7dzhjussp@fsr-ub1664-175/ 
devfreq works without your patchset ) Is there anything I'm missing that 
is not yet merged in v5.11?


Can I test anything else that would help?

/sys/class/devfreq# cat */cur_freq
13334
2500
25641026
2500
8
2500
0
2500
2500
2500
0

the available freqs look ok (opp table removed from device dts, but you 
don't read that anymore anyway):


cat */available_frequencies
1 4 8
2500 1 8
2500 1 3
2500 2
2500 8
2500 8
2500 3
2500 5
2500 5
2500 12800 5
2500 1

where ls is:

3270.noc 

3d40.memory-controller 

soc@0:pl301@0 

soc@0:pl301@1 

soc@0:pl301@2 

soc@0:pl301@3 

soc@0:pl301@4 

soc@0:pl301@5 

soc@0:pl301@6 

soc@0:pl301@7 


soc@0:pl301@8

thanks,
martin


[PATCH v3 5/5] arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

2021-02-19 Thread Martin Kepplinger
On Birch I can never reach 220 and hence the display would never
turn off. Tests suggest 120 to be a good threshold value for all Birch
devices.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
index d77fc5df3f06..73bd431cbd6a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
@@ -25,5 +25,5 @@
 };
 
  {
-   proximity-near-level = <220>;
+   proximity-near-level = <120>;
 };
-- 
2.20.1



[PATCH v3 1/5] arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay

2021-02-19 Thread Martin Kepplinger
From: Guido Günther 

The PMIC driver now sets appropriate default delays.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index dd217a0760e9..88508890063f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -315,7 +315,6 @@
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
-   regulator-enable-ramp-delay = <200>;
rohm,dvs-run-voltage = <90>;
};
 
-- 
2.20.1



[PATCH v3 2/5] arm64: dts: librem5: Drop assigned-clocks from SAI2

2021-02-19 Thread Martin Kepplinger
From: Guido Günther 

IMX8MQ_AUDIO_PLL1 and IMX8MQ_AUDIO_PLL2 are setup to the same rates
right on the clock controller.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 06a4799b6aeb..c2bbbdeb93e3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1051,8 +1051,6 @@
assigned-clocks = < IMX8MQ_CLK_SAI2>;
assigned-clock-parents = < IMX8MQ_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
status = "okay";
 };
 
-- 
2.20.1



[PATCH v3 4/5] arm64: dts: librem5: protect some partitions of the nor-flash

2021-02-19 Thread Martin Kepplinger
From: Angus Ainslie 

These sections should be read only as they contain important data.

Signed-off-by: Angus Ainslie 
Signed-off-by: Martin Kepplinger 
---
 .../boot/dts/freescale/imx8mq-librem5.dtsi  | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index c2bbbdeb93e3..d39ae27c8e42 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -258,6 +258,23 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <100>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "protected0";
+   reg = <0x0 0x3>;
+   read-only;
+   };
+   partition@3 {
+   label = "protected1";
+   reg = <0x3 0x1>;
+   read-only;
+   };
+   partition@4 {
+   label = "rw";
+   reg = <0x4 0x1C>;
+   };
};
 };
 
-- 
2.20.1



[PATCH v3 3/5] arm64: defconfig: Enable devfreq support for i.MX8MQ

2021-02-19 Thread Martin Kepplinger
From: Guido Günther 

This is needed to make DRAM frequency scaling via devfreq as used
on the Librem 5 and Librem 5 Devkit.

With the interconnect support enabled we now need imx devfreq on top
to make this work.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/configs/defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index d612f633b771..e9f3e47933d5 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1022,6 +1022,8 @@ CONFIG_ARCH_TEGRA_186_SOC=y
 CONFIG_ARCH_TEGRA_194_SOC=y
 CONFIG_ARCH_TEGRA_234_SOC=y
 CONFIG_TI_SCI_PM_DOMAINS=y
+CONFIG_ARM_IMX_BUS_DEVFREQ=m
+CONFIG_ARM_IMX8M_DDRC_DEVFREQ=m
 CONFIG_EXTCON_PTN5150=m
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_EXTCON_USBC_CROS_EC=y
-- 
2.20.1



[PATCH v3 0/5] arm64: dts: librem5 phone and devkit dts and config updates

2021-02-19 Thread Martin Kepplinger
hi,

Small updates to Purism hardware in order to maintain support.

revision history

v3: (thanks for the patience, Krzysztof)
 * fix flash partition DT syntax

v2: (thank you, Krzysztof)
 * fix flash partition DT syntax
 * add one reviewed tag
https://lore.kernel.org/linux-arm-kernel/20210217111944.1416-1-martin.kepplin...@puri.sm/

v1:
https://lore.kernel.org/linux-arm-kernel/20210208131527.24463-1-martin.kepplin...@puri.sm/T/


Angus Ainslie (1):
  arm64: dts: librem5: protect some partitions of the nor-flash

Guido Günther (3):
  arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay
  arm64: dts: librem5: Drop assigned-clocks from SAI2
  arm64: defconfig: Enable devfreq support for i.MX8MQ

Martin Kepplinger (1):
  arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

 .../dts/freescale/imx8mq-librem5-devkit.dts   |  1 -
 .../boot/dts/freescale/imx8mq-librem5-r2.dts  |  2 +-
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 19 +--
 arch/arm64/configs/defconfig  |  2 ++
 4 files changed, 20 insertions(+), 4 deletions(-)

-- 
2.20.1



[PATCH v2 5/5] arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

2021-02-17 Thread Martin Kepplinger
On Birch I can never reach 220 and hence the display would never
turn off. Tests suggest 120 to be a good threshold value for all Birch
devices.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
index d77fc5df3f06..73bd431cbd6a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
@@ -25,5 +25,5 @@
 };
 
  {
-   proximity-near-level = <220>;
+   proximity-near-level = <120>;
 };
-- 
2.20.1



[PATCH v2 3/5] arm64: defconfig: Enable devfreq support for i.MX8MQ

2021-02-17 Thread Martin Kepplinger
From: Guido Günther 

This is needed to make DRAM frequency scaling via devfreq as used
on the Librem 5 and Librem 5 Devkit.

With the interconnect support enabled we now need imx devfreq on top
to make this work.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/configs/defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index d612f633b771..e9f3e47933d5 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1022,6 +1022,8 @@ CONFIG_ARCH_TEGRA_186_SOC=y
 CONFIG_ARCH_TEGRA_194_SOC=y
 CONFIG_ARCH_TEGRA_234_SOC=y
 CONFIG_TI_SCI_PM_DOMAINS=y
+CONFIG_ARM_IMX_BUS_DEVFREQ=m
+CONFIG_ARM_IMX8M_DDRC_DEVFREQ=m
 CONFIG_EXTCON_PTN5150=m
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_EXTCON_USBC_CROS_EC=y
-- 
2.20.1



[PATCH v2 4/5] arm64: dts: librem5: protect some partitions of the nor-flash

2021-02-17 Thread Martin Kepplinger
From: Angus Ainslie 

These sections should be read only as they contain important data.

Signed-off-by: Angus Ainslie 
Signed-off-by: Martin Kepplinger 
---
 .../arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index c2bbbdeb93e3..3c0462f81b3a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -258,6 +258,22 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <100>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   label = "protected0";
+   reg = <0x 0x0003>;
+   read-only;
+   };
+   partition@3 {
+   label = "protected1";
+   reg = <0x0003 0x0001>;
+   read-only;
+   };
+   partition@4 {
+   label = "rw";
+   reg = <0x0004 0x001C>;
+   };
};
 };
 
-- 
2.20.1



[PATCH v2 1/5] arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay

2021-02-17 Thread Martin Kepplinger
From: Guido Günther 

The PMIC driver now sets appropriate default delays.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index dd217a0760e9..88508890063f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -315,7 +315,6 @@
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
-   regulator-enable-ramp-delay = <200>;
rohm,dvs-run-voltage = <90>;
};
 
-- 
2.20.1



[PATCH v2 2/5] arm64: dts: librem5: Drop assigned-clocks from SAI2

2021-02-17 Thread Martin Kepplinger
From: Guido Günther 

IMX8MQ_AUDIO_PLL1 and IMX8MQ_AUDIO_PLL2 are setup to the same rates
right on the clock controller.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 06a4799b6aeb..c2bbbdeb93e3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1051,8 +1051,6 @@
assigned-clocks = < IMX8MQ_CLK_SAI2>;
assigned-clock-parents = < IMX8MQ_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
status = "okay";
 };
 
-- 
2.20.1



[PATCH v2 0/5] arm64: dts: librem5 phone and devkit dts and config updates

2021-02-17 Thread Martin Kepplinger
Small updates to Purism hardware in order to maintain support.

revision history

v2: (thank you, Krzysztof)
 * fix flash partition DT syntax
 * add one reviewed tag

v1:
https://lore.kernel.org/linux-arm-kernel/20210208131527.24463-1-martin.kepplin...@puri.sm/T/#t

Angus Ainslie (1):
  arm64: dts: librem5: protect some partitions of the nor-flash

Guido Günther (3):
  arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay
  arm64: dts: librem5: Drop assigned-clocks from SAI2
  arm64: defconfig: Enable devfreq support for i.MX8MQ

Martin Kepplinger (1):
  arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

 .../dts/freescale/imx8mq-librem5-devkit.dts|  1 -
 .../boot/dts/freescale/imx8mq-librem5-r2.dts   |  2 +-
 .../boot/dts/freescale/imx8mq-librem5.dtsi | 18 --
 arch/arm64/configs/defconfig   |  2 ++
 4 files changed, 19 insertions(+), 4 deletions(-)

-- 
2.20.1



[PATCH 5/5] arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

2021-02-08 Thread Martin Kepplinger
On Birch I can never reach 220 and hence the display would never
turn off. Tests suggest 120 to be a good threshold value for all Birch
devices.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
index d77fc5df3f06..73bd431cbd6a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r2.dts
@@ -25,5 +25,5 @@
 };
 
  {
-   proximity-near-level = <220>;
+   proximity-near-level = <120>;
 };
-- 
2.20.1



[PATCH 4/5] arm64: dts: librem5: protect some partitions of the nor-flash

2021-02-08 Thread Martin Kepplinger
From: Angus Ainslie 

These sections should be read only as they contain important data.

Signed-off-by: Angus Ainslie 
Signed-off-by: Martin Kepplinger 
---
 .../arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index c2bbbdeb93e3..9867e2a50008 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -258,6 +258,22 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <100>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0x {
+   label = "protected0";
+   reg = <0x 0x0003>;
+   read-only;
+   };
+   partition@0x0003 {
+   label = "protected1";
+   reg = <0x0003 0x0001>;
+   read-only;
+   };
+   partition@0x0004 {
+   label = "rw";
+   reg = <0x0004 0x001C>;
+   };
};
 };
 
-- 
2.20.1



[PATCH 2/5] arm64: dts: librem5: Drop assigned-clocks from SAI2

2021-02-08 Thread Martin Kepplinger
From: Guido Günther 

IMX8MQ_AUDIO_PLL1 and IMX8MQ_AUDIO_PLL2 are setup to the same rates
right on the clock controller.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 06a4799b6aeb..c2bbbdeb93e3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1051,8 +1051,6 @@
assigned-clocks = < IMX8MQ_CLK_SAI2>;
assigned-clock-parents = < IMX8MQ_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
status = "okay";
 };
 
-- 
2.20.1



[PATCH 0/5] arm64: dts: librem5 phone and devkit dts and config updates

2021-02-08 Thread Martin Kepplinger
Small updates to Purism hardware in order to maintain support:

Angus Ainslie (1):
  arm64: dts: librem5: protect some partitions of the nor-flash

Guido Günther (3):
  arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay
  arm64: dts: librem5: Drop assigned-clocks from SAI2
  arm64: defconfig: Enable devfreq support for i.MX8MQ

Martin Kepplinger (1):
  arm64: dts: imx8mq-librem5-r2: set nearlevel to 120

 .../dts/freescale/imx8mq-librem5-devkit.dts|  1 -
 .../boot/dts/freescale/imx8mq-librem5-r2.dts   |  2 +-
 .../boot/dts/freescale/imx8mq-librem5.dtsi | 18 --
 arch/arm64/configs/defconfig   |  2 ++
 4 files changed, 19 insertions(+), 4 deletions(-)

-- 
2.20.1



[PATCH 1/5] arm64: dts: imx8mq-librem5-devkit: Drop buck3 startup-ramp-delay

2021-02-08 Thread Martin Kepplinger
From: Guido Günther 

The PMIC driver now sets appropriate default delays.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index dd217a0760e9..88508890063f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -315,7 +315,6 @@
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
-   regulator-enable-ramp-delay = <200>;
rohm,dvs-run-voltage = <90>;
};
 
-- 
2.20.1



[PATCH 3/5] arm64: defconfig: Enable devfreq support for i.MX8MQ

2021-02-08 Thread Martin Kepplinger
From: Guido Günther 

This is needed to make DRAM frequency scaling via devfreq as used
on the Librem 5 and Librem 5 Devkit.

With the interconnect support enabled we now need imx devfreq on top
to make this work.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/configs/defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 5348c0be2fcf..ceeb1c1c10ea 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1019,6 +1019,8 @@ CONFIG_ARCH_TEGRA_186_SOC=y
 CONFIG_ARCH_TEGRA_194_SOC=y
 CONFIG_ARCH_TEGRA_234_SOC=y
 CONFIG_TI_SCI_PM_DOMAINS=y
+CONFIG_ARM_IMX_BUS_DEVFREQ=m
+CONFIG_ARM_IMX8M_DDRC_DEVFREQ=m
 CONFIG_EXTCON_PTN5150=m
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_EXTCON_USBC_CROS_EC=y
-- 
2.20.1



[PATCH] dt-bindings: mxsfb: Add interconnect bindings for LCDIF path

2021-01-27 Thread Martin Kepplinger
Add optional interconnect properties for the dram path requests.

Signed-off-by: Martin Kepplinger 
---
 Documentation/devicetree/bindings/display/fsl,lcdif.yaml | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/fsl,lcdif.yaml 
b/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
index a4c3064c778c..44d744800a7c 100644
--- a/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
+++ b/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
@@ -50,6 +50,14 @@ properties:
   interrupts:
 maxItems: 1
 
+  interconnects:
+items:
+  - description: Interconnect path between LCDIF and main memory
+
+  interconnect-names:
+items:
+  - const: dram
+
   port:
 $ref: /schemas/graph.yaml#/properties/port
 description: The LCDIF output port
-- 
2.20.1



Re: [PATCH] scsi_logging: print cdb into new line after opcode

2021-01-24 Thread Martin Kepplinger

On 23.01.21 04:09, Martin K. Petersen wrote:


Ewan,


sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01
00

Print the cdb into a new line in any case, not only when cmd_len is
greater than 16. The above example error will then read:

sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
28 00 01 c0 09 00 00 00 08 00


I'd rather we not change this.


I agree. While the current format is suboptimal, there are lots of
things out there parsing these error messages.



hi Ewan, hi Martin,

That's totally fine. I had this on my list since Douglas suggested to 
change this during a discussion back in july and I basically wanted to 
get opinions:

https://lore.kernel.org/linux-scsi/31f1ec62-7047-a34b-fdcb-5ea2a2104...@interlog.com/

thanks,
 martin


[PATCH] scsi_logging: print cdb into new line after opcode

2021-01-22 Thread Martin Kepplinger
The current log message results in a line like the following where
the first byte is duplicated, giving a wrong impression:

sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01 00

Print the cdb into a new line in any case, not only when cmd_len is
greater than 16. The above example error will then read:

sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
28 00 01 c0 09 00 00 00 08 00

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_logging.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 8ea44c6595ef..0081d3936f83 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -200,10 +200,11 @@ void scsi_print_command(struct scsi_cmnd *cmd)
if (off >= logbuf_len)
goto out_printk;
 
+   /* Print opcode in one line and use separate lines for CDB */
+   off += scnprintf(logbuf + off, logbuf_len - off, "\n");
+
/* print out all bytes in cdb */
if (cmd->cmd_len > 16) {
-   /* Print opcode in one line and use separate lines for CDB */
-   off += scnprintf(logbuf + off, logbuf_len - off, "\n");
dev_printk(KERN_INFO, >device->sdev_gendev, "%s", logbuf);
for (k = 0; k < cmd->cmd_len; k += 16) {
size_t linelen = min(cmd->cmd_len - k, 16);
@@ -224,7 +225,6 @@ void scsi_print_command(struct scsi_cmnd *cmd)
goto out;
}
if (!WARN_ON(off > logbuf_len - 49)) {
-   off += scnprintf(logbuf + off, logbuf_len - off, " ");
hex_dump_to_buffer(cmd->cmnd, cmd->cmd_len, 16, 1,
   logbuf + off, logbuf_len - off,
   false);
-- 
2.20.1



[PATCH] scsi: sd: print write through due to no caching mode page as warning

2021-01-22 Thread Martin Kepplinger
For SD cardreaders it's extremely common not to find cache on disk.
The following error messages are thus very common and don't point
to a real error one could try to fix but rather describe how the disk
works:

sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through

Print these messages as warnings instead of errors.

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/sd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index e7c52d6df4dc..db0171c81c5b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2808,7 +2808,8 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
}
}
 
-   sd_first_printk(KERN_ERR, sdkp, "No Caching mode page found\n");
+   sd_first_printk(KERN_WARNING, sdkp,
+   "No Caching mode page found\n");
goto defaults;
 
Page_found:
@@ -2863,7 +2864,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
"Assuming drive cache: write back\n");
sdkp->WCE = 1;
} else {
-   sd_first_printk(KERN_ERR, sdkp,
+   sd_first_printk(KERN_WARNING, sdkp,
"Assuming drive cache: write through\n");
sdkp->WCE = 0;
}
-- 
2.20.1



[PATCH v2 0/9] Config and devicetree updates for the Librem 5 phone

2021-01-18 Thread Martin Kepplinger
This is another set of updates in order to maintain support for the
Librem 5 phone:

revision history

v2: thanks Shawn and Krzysztof
* fix dts style issues in "enable the LCD panel"
* reorder for the bindings to go before the dts usage
* add ack and review tags

v1: 
https://lore.kernel.org/linux-arm-kernel/20210112095151.4995-1-martin.kepplin...@puri.sm/

Guido Günther (5):
  arm64: defconfig: Enable vibra-pwm
  arm64: dts: imx8mq-librem5: Mark charger IRQ as High-Z
  arm64: dts: imx8mq-librem5: Don't mark buck3 as always on
  arm64: dts: imx8mq-librem5: Add usb-c chip as supplier for the charger
  arm64: dts: imx8mq-librem5: Add LCD_1V8 regulator

Martin Kepplinger (4):
  arm64: dts: imx8mq-librem5: enable the LCD panel
  arm64: dts: imx8mq-librem5: set regulators boot-on
  dt-bindings: arm: fsl: Add the librem 5 Evergreen revision
  arm64: dts: Add Librem5 Evergreen

 .../devicetree/bindings/arm/fsl.yaml  |  1 +
 arch/arm64/boot/dts/freescale/Makefile|  1 +
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 35 
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 85 ++-
 arch/arm64/configs/defconfig  |  1 +
 5 files changed, 119 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts

-- 
2.20.1



[PATCH v2 3/9] arm64: dts: imx8mq-librem5: Don't mark buck3 as always on

2021-01-18 Thread Martin Kepplinger
From: Guido Günther 

With the pmic driver fixed we can now shut off the regulator in the gpc.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 9928e941ee21..95d710831f28 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -679,7 +679,6 @@
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
rohm,dvs-run-voltage = <90>;
-   regulator-always-on;
};
 
buck4_reg: BUCK4 {
-- 
2.20.1



[PATCH v2 4/9] arm64: dts: imx8mq-librem5: Add usb-c chip as supplier for the charger

2021-01-18 Thread Martin Kepplinger
From: Guido Günther 

The tps65982 feeds the bq25895 charge controller on the Librem 5.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 95d710831f28..d7d807cd72b3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -928,6 +928,7 @@
ti,use-vinmin-threshold = <1>; /* enable VINDPM */
ti,vinmin-threshold = <390>; /* uV */
monitored-battery = <>;
+   power-supplies = <_pd>;
};
 };
 
-- 
2.20.1



[PATCH v2 7/9] arm64: dts: imx8mq-librem5: set regulators boot-on

2021-01-18 Thread Martin Kepplinger
Expect all those regulators to be turned on initially.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index bf86402cda30..06a4799b6aeb 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -682,6 +682,7 @@
regulator-name = "buck1";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <90>;
rohm,dvs-idle-voltage = <85>;
@@ -693,6 +694,7 @@
regulator-name = "buck2";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <100>;
rohm,dvs-idle-voltage = <90>;
@@ -703,6 +705,7 @@
regulator-name = "buck3";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
rohm,dvs-run-voltage = <90>;
};
 
@@ -717,6 +720,7 @@
regulator-name = "buck5";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <135>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -724,6 +728,7 @@
regulator-name = "buck6";
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -731,6 +736,7 @@
regulator-name = "buck7";
regulator-min-microvolt = <1605000>;
regulator-max-microvolt = <1995000>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -738,6 +744,7 @@
regulator-name = "buck8";
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -745,6 +752,7 @@
regulator-name = "ldo1";
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
/* leave on for snvs power button */
regulator-always-on;
};
@@ -753,6 +761,7 @@
regulator-name = "ldo2";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <90>;
+   regulator-boot-on;
/* leave on for snvs power button */
regulator-always-on;
};
@@ -761,6 +770,7 @@
regulator-name = "ldo3";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -768,6 +778,7 @@
regulator-name = "ldo4";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -784,6 +795,7 @@
 

[PATCH v2 5/9] arm64: dts: imx8mq-librem5: Add LCD_1V8 regulator

2021-01-18 Thread Martin Kepplinger
From: Guido Günther 

It's a supply for to touch and LCD.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index d7d807cd72b3..f77b51d3c132 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -82,6 +82,20 @@
enable-active-high;
};
 
+   reg_lcd_1v8: regulator-lcd-1v8 {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_dsien>;
+   regulator-name = "LCD_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_vdd_1v8>;
+   gpio = < 5 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   /* Otherwise i2c3 is not functional */
+   regulator-always-on;
+   };
+
reg_lcd_3v4: regulator-lcd-3v4 {
compatible = "regulator-fixed";
regulator-name = "LCD_3V4";
@@ -892,6 +906,7 @@
interrupts = <27 IRQ_TYPE_EDGE_FALLING>;
touchscreen-size-x = <720>;
touchscreen-size-y = <1440>;
+   vcc-supply = <_lcd_1v8>;
};
 };
 
-- 
2.20.1



[PATCH v2 6/9] arm64: dts: imx8mq-librem5: enable the LCD panel

2021-01-18 Thread Martin Kepplinger
This enables the Librem5's ft8006p based LCD panel driven by the
imx8mq's Northwest Logic DSI IP core and mxsfb display controller.

Signed-off-by: Martin Kepplinger 
---
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 53 ++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index f77b51d3c132..bf86402cda30 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -310,6 +310,17 @@
>;
};
 
+   pinctrl_dsirst: dsirstgrp {
+   fsl,pins = <
+   /* DSI_RST */
+   MX8MQ_IOMUXC_ENET_RD3_GPIO1_IO290x83
+   /* DSI_TE */
+   MX8MQ_IOMUXC_ENET_RD2_GPIO1_IO280x83
+   /* TP_RST */
+   MX8MQ_IOMUXC_ENET_RX_CTL_GPIO1_IO24 0x83
+   >;
+   };
+
pinctrl_ecspi1: ecspigrp {
fsl,pins = <
MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI0x83
@@ -817,12 +828,12 @@
compatible = "tps65132";
reg = <0x3e>;
 
-   outp {
+   reg_lcd_avdd: outp {
regulator-name = "LCD_AVDD";
vin-supply = <_lcd_3v4>;
};
 
-   outn {
+   reg_lcd_avee: outn {
regulator-name = "LCD_AVEE";
vin-supply = <_lcd_3v4>;
};
@@ -947,6 +958,44 @@
};
 };
 
+ {
+   status = "okay";
+};
+
+_dsi {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "okay";
+
+   lcd_panel: panel@0 {
+   compatible = "mantix,mlaf057we51-x";
+   reg = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_dsirst>;
+   avdd-supply = <_lcd_avdd>;
+   avee-supply = <_lcd_avee>;
+   vddi-supply = <_lcd_1v8>;
+   backlight = <_dsi>;
+   reset-gpios = < 29 GPIO_ACTIVE_LOW>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_dsi_out>;
+   };
+   };
+   };
+
+   ports {
+   port@1 {
+   reg = <1>;
+
+   mipi_dsi_out: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+};
+
 _gpu {
power-supply = <_reg>;
 };
-- 
2.20.1



[PATCH v2 8/9] dt-bindings: arm: fsl: Add the librem 5 Evergreen revision

2021-01-18 Thread Martin Kepplinger
Add an entry for the Librem 5 phone, Evergreen revision which is supported
by "r4". Schematics and more information can be found at
https://developer.puri.sm/Librem5/Hardware_Reference/Evergreen.html

Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 2ae66407e2aa..aaac7ef78b38 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -738,6 +738,7 @@ properties:
   - enum:
   - purism,librem5r2  # Purism Librem5 phone "Chestnut"
   - purism,librem5r3  # Purism Librem5 phone "Dogwood"
+  - purism,librem5r4  # Purism Librem5 phone "Evergreen"
   - const: purism,librem5
   - const: fsl,imx8mq
 
-- 
2.20.1



[PATCH v2 9/9] arm64: dts: Add Librem5 Evergreen

2021-01-18 Thread Martin Kepplinger
Add librem5-r4 with specifics to that revision like the near-level,
battery and charger properties. For schematics and more information,
see https://developer.puri.sm/Librem5/Hardware_Reference/Evergreen.html

Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/Makefile|  1 +
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 35 +++
 2 files changed, 36 insertions(+)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts

diff --git a/arch/arm64/boot/dts/freescale/Makefile 
b/arch/arm64/boot/dts/freescale/Makefile
index 38559943c15d..e814ee98fecf 100644
--- a/arch/arm64/boot/dts/freescale/Makefile
+++ b/arch/arm64/boot/dts/freescale/Makefile
@@ -48,6 +48,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx8mq-hummingboard-pulse.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-devkit.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r2.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r3.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r4.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-nitrogen.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-phanbell.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-pico-pi.dtb
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
new file mode 100644
index ..cbfb49aa2563
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2020 Purism SPC 
+
+/dts-v1/;
+
+#include "imx8mq-librem5.dtsi"
+
+/ {
+   model = "Purism Librem 5r4";
+   compatible = "purism,librem5r4", "purism,librem5", "fsl,imx8mq";
+};
+
+_gyro {
+   mount-matrix =  "1",  "0",  "0",
+   "0",  "1",  "0",
+   "0",  "0", "-1";
+};
+
+ {
+   maxim,rsns-microohm = <1667>;
+};
+
+ {
+   ti,battery-regulation-voltage = <420>; /* uV */
+   ti,charge-current = <150>; /* uA */
+   ti,termination-current = <144000>;  /* uA */
+};
+
+_backlight {
+   led-max-microamp = <25000>;
+};
+
+ {
+   proximity-near-level = <10>;
+};
-- 
2.20.1



[PATCH v2 1/9] arm64: defconfig: Enable vibra-pwm

2021-01-18 Thread Martin Kepplinger
From: Guido Günther 

The haptic motor for the Librem 5 uses this.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 15fe99544c67..91a034924a70 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -392,6 +392,7 @@ CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
 CONFIG_INPUT_PM8XXX_VIBRATOR=m
+CONFIG_INPUT_PWM_VIBRA=m
 CONFIG_INPUT_HISI_POWERKEY=y
 # CONFIG_SERIO_SERPORT is not set
 CONFIG_SERIO_AMBAKMI=y
-- 
2.20.1



[PATCH v2 2/9] arm64: dts: imx8mq-librem5: Mark charger IRQ as High-Z

2021-01-18 Thread Martin Kepplinger
From: Guido Günther 

This is consistent with other IRQs and makes keeps currents low.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index f85d30a0c2cb..9928e941ee21 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -276,7 +276,7 @@
pinctrl_charger_in: chargeringrp {
fsl,pins = <
/* CHRG_INT */
-   MX8MQ_IOMUXC_NAND_CE2_B_GPIO3_IO3   0x00
+   MX8MQ_IOMUXC_NAND_CE2_B_GPIO3_IO3   0x80
/* CHG_STATUS_B */
MX8MQ_IOMUXC_NAND_ALE_GPIO3_IO0 0x80
>;
-- 
2.20.1



Re: [PATCH v4 4/5] arm64: dts: imx8mq: Add interconnect for lcdif

2021-01-15 Thread Martin Kepplinger




On 15.01.21 10:47, Shawn Guo wrote:

On Thu, Jan 07, 2021 at 01:17:53PM +0100, Martin Kepplinger wrote:

Add interconnect ports for lcdif to set bus capabilities.

Signed-off-by: Martin Kepplinger 
---
  arch/arm64/boot/dts/freescale/imx8mq.dtsi | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 89e7de2e7f7a..9300be8c9b53 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -11,6 +11,7 @@
  #include "dt-bindings/input/input.h"
  #include 
  #include 
+#include 
  #include "imx8mq-pinfunc.h"
  
  / {

@@ -522,6 +523,8 @@
  < IMX8MQ_VIDEO_PLL1>,
  < IMX8MQ_VIDEO_PLL1_OUT>;
assigned-clock-rates = <0>, <0>, <0>, 
<59400>;
+   interconnects = < IMX8MQ_ICM_LCDIF  
IMX8MQ_ICS_DRAM>;
+   interconnect-names = "dram";


Hmm, two interconnect phandles but only one name?



Well it's one interconnect path that would more accurately be named 
"lcdif-dram" if that's what you mean. I removed "lcdif-" because it's 
the lcdif node, but maybe we should name it lcdif-dram after all. at 
least that's how others describe it.


  martin


[PATCH 7/9] arm64: dts: imx8mq-librem5: set regulators boot-on

2021-01-12 Thread Martin Kepplinger
Expect all those regulators to be turned on initially.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 440931f81c12..9029498ea775 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -682,6 +682,7 @@
regulator-name = "buck1";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <90>;
rohm,dvs-idle-voltage = <85>;
@@ -693,6 +694,7 @@
regulator-name = "buck2";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <100>;
rohm,dvs-idle-voltage = <90>;
@@ -703,6 +705,7 @@
regulator-name = "buck3";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
+   regulator-boot-on;
rohm,dvs-run-voltage = <90>;
};
 
@@ -717,6 +720,7 @@
regulator-name = "buck5";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <135>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -724,6 +728,7 @@
regulator-name = "buck6";
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -731,6 +736,7 @@
regulator-name = "buck7";
regulator-min-microvolt = <1605000>;
regulator-max-microvolt = <1995000>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -738,6 +744,7 @@
regulator-name = "buck8";
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -745,6 +752,7 @@
regulator-name = "ldo1";
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
/* leave on for snvs power button */
regulator-always-on;
};
@@ -753,6 +761,7 @@
regulator-name = "ldo2";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <90>;
+   regulator-boot-on;
/* leave on for snvs power button */
regulator-always-on;
};
@@ -761,6 +770,7 @@
regulator-name = "ldo3";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -768,6 +778,7 @@
regulator-name = "ldo4";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
+   regulator-boot-on;
regulator-always-on;
};
 
@@ -784,6 +795,7 @@
 

[PATCH 8/9] arm64: dts: Add Librem5 Evergreen

2021-01-12 Thread Martin Kepplinger
Add librem5-r4 with specifics to that revision like the near-level,
battery and charger properties. For schematics and more information,
see https://developer.puri.sm/Librem5/Hardware_Reference/Evergreen.html

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/Makefile|  1 +
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 35 +++
 2 files changed, 36 insertions(+)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts

diff --git a/arch/arm64/boot/dts/freescale/Makefile 
b/arch/arm64/boot/dts/freescale/Makefile
index 38559943c15d..e814ee98fecf 100644
--- a/arch/arm64/boot/dts/freescale/Makefile
+++ b/arch/arm64/boot/dts/freescale/Makefile
@@ -48,6 +48,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx8mq-hummingboard-pulse.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-devkit.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r2.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r3.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx8mq-librem5-r4.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-nitrogen.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-phanbell.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mq-pico-pi.dtb
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
new file mode 100644
index ..cbfb49aa2563
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2020 Purism SPC 
+
+/dts-v1/;
+
+#include "imx8mq-librem5.dtsi"
+
+/ {
+   model = "Purism Librem 5r4";
+   compatible = "purism,librem5r4", "purism,librem5", "fsl,imx8mq";
+};
+
+_gyro {
+   mount-matrix =  "1",  "0",  "0",
+   "0",  "1",  "0",
+   "0",  "0", "-1";
+};
+
+ {
+   maxim,rsns-microohm = <1667>;
+};
+
+ {
+   ti,battery-regulation-voltage = <420>; /* uV */
+   ti,charge-current = <150>; /* uA */
+   ti,termination-current = <144000>;  /* uA */
+};
+
+_backlight {
+   led-max-microamp = <25000>;
+};
+
+ {
+   proximity-near-level = <10>;
+};
-- 
2.20.1



[PATCH 9/9] dt-bindings: arm: fsl: Add the librem 5 Evergreen revision

2021-01-12 Thread Martin Kepplinger
Add an entry for the Librem 5 phone, Evergreen revision which is supported
by "r4". Schematics and more information can be found at
https://developer.puri.sm/Librem5/Hardware_Reference/Evergreen.html

Signed-off-by: Martin Kepplinger 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 34000f7fbe02..5921ccf218d9 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -724,6 +724,7 @@ properties:
   - enum:
   - purism,librem5r2  # Purism Librem5 phone "Chestnut"
   - purism,librem5r3  # Purism Librem5 phone "Dogwood"
+  - purism,librem5r4  # Purism Librem5 phone "Evergreen"
   - const: purism,librem5
   - const: fsl,imx8mq
 
-- 
2.20.1



[PATCH 6/9] arm64: dts: imx8mq-librem5: enable the LCD panel

2021-01-12 Thread Martin Kepplinger
This enables the Librem5's ft8006p based LCD panel driven by the
imx8mq's Northwest Logic DSI IP core and mxsfb display controller.

Signed-off-by: Martin Kepplinger 
---
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 51 ++-
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index f77b51d3c132..440931f81c12 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -310,6 +310,17 @@
>;
};
 
+   pinctrl_dsirst: dsirstgrp {
+   fsl,pins = <
+   /* DSI_RST */
+   MX8MQ_IOMUXC_ENET_RD3_GPIO1_IO290x83
+   /* DSI_TE */
+   MX8MQ_IOMUXC_ENET_RD2_GPIO1_IO280x83
+   /* TP_RST */
+   MX8MQ_IOMUXC_ENET_RX_CTL_GPIO1_IO24 0x83
+   >;
+   };
+
pinctrl_ecspi1: ecspigrp {
fsl,pins = <
MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI0x83
@@ -817,12 +828,12 @@
compatible = "tps65132";
reg = <0x3e>;
 
-   outp {
+   reg_lcd_avdd: outp {
regulator-name = "LCD_AVDD";
vin-supply = <_lcd_3v4>;
};
 
-   outn {
+   reg_lcd_avee: outn {
regulator-name = "LCD_AVEE";
vin-supply = <_lcd_3v4>;
};
@@ -947,6 +958,42 @@
};
 };
 
+ {
+   status = "okay";
+};
+
+_dsi {
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   lcd_panel: panel@0 {
+   compatible = "mantix,mlaf057we51-x";
+   reg = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_dsirst>;
+   avdd-supply = <_lcd_avdd>;
+   avee-supply = <_lcd_avee>;
+   vddi-supply = <_lcd_1v8>;
+   backlight = <_dsi>;
+   reset-gpios = < 29 GPIO_ACTIVE_LOW>;
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_dsi_out>;
+   };
+   };
+   };
+
+   ports {
+   port@1 {
+   reg = <1>;
+   mipi_dsi_out: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+};
+
 _gpu {
power-supply = <_reg>;
 };
-- 
2.20.1



[PATCH 1/9] arm64: defconfig: Enable vibra-pwm

2021-01-12 Thread Martin Kepplinger
From: Guido Günther 

The haptic motor for the Librem 5 uses this.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 838301650a79..0a17b970d6bd 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -391,6 +391,7 @@ CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
 CONFIG_INPUT_PM8XXX_VIBRATOR=m
+CONFIG_INPUT_PWM_VIBRA=m
 CONFIG_INPUT_HISI_POWERKEY=y
 # CONFIG_SERIO_SERPORT is not set
 CONFIG_SERIO_AMBAKMI=y
-- 
2.20.1



[PATCH 5/9] arm64: dts: imx8mq-librem5: Add LCD_1V8 regulator

2021-01-12 Thread Martin Kepplinger
From: Guido Günther 

It's a supply for to touch and LCD.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index d7d807cd72b3..f77b51d3c132 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -82,6 +82,20 @@
enable-active-high;
};
 
+   reg_lcd_1v8: regulator-lcd-1v8 {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_dsien>;
+   regulator-name = "LCD_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_vdd_1v8>;
+   gpio = < 5 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   /* Otherwise i2c3 is not functional */
+   regulator-always-on;
+   };
+
reg_lcd_3v4: regulator-lcd-3v4 {
compatible = "regulator-fixed";
regulator-name = "LCD_3V4";
@@ -892,6 +906,7 @@
interrupts = <27 IRQ_TYPE_EDGE_FALLING>;
touchscreen-size-x = <720>;
touchscreen-size-y = <1440>;
+   vcc-supply = <_lcd_1v8>;
};
 };
 
-- 
2.20.1



[PATCH 3/9] arm64: dts: imx8mq-librem5: Don't mark buck3 as always on

2021-01-12 Thread Martin Kepplinger
From: Guido Günther 

With the pmic driver fixed we can now shut off the regulator in the gpc.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 9928e941ee21..95d710831f28 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -679,7 +679,6 @@
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
rohm,dvs-run-voltage = <90>;
-   regulator-always-on;
};
 
buck4_reg: BUCK4 {
-- 
2.20.1



[PATCH 0/9] Config and devicetree updates for the Librem 5 phone

2021-01-12 Thread Martin Kepplinger
This is another set of updates in order to maintain support for the
Librem 5 phone:

Guido Günther (5):
  arm64: defconfig: Enable vibra-pwm
  arm64: dts: imx8mq-librem5: Mark charger IRQ as High-Z
  arm64: dts: imx8mq-librem5: Don't mark buck3 as always on
  arm64: dts: imx8mq-librem5: Add usb-c chip as supplier for the charger
  arm64: dts: imx8mq-librem5: Add LCD_1V8 regulator

Martin Kepplinger (4):
  arm64: dts: imx8mq-librem5: enable the LCD panel
  arm64: dts: imx8mq-librem5: set regulators boot-on
  arm64: dts: Add Librem5 Evergreen
  dt-bindings: arm: fsl: Add the librem 5 Evergreen revision

 .../devicetree/bindings/arm/fsl.yaml  |  1 +
 arch/arm64/boot/dts/freescale/Makefile|  1 +
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 35 
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 83 ++-
 arch/arm64/configs/defconfig  |  1 +
 5 files changed, 117 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts

-- 
2.20.1



[PATCH 4/9] arm64: dts: imx8mq-librem5: Add usb-c chip as supplier for the charger

2021-01-12 Thread Martin Kepplinger
From: Guido Günther 

The tps65982 feeds the bq25895 charge controller on the Librem 5.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 95d710831f28..d7d807cd72b3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -928,6 +928,7 @@
ti,use-vinmin-threshold = <1>; /* enable VINDPM */
ti,vinmin-threshold = <390>; /* uV */
monitored-battery = <>;
+   power-supplies = <_pd>;
};
 };
 
-- 
2.20.1



[PATCH 2/9] arm64: dts: imx8mq-librem5: Mark charger IRQ as High-Z

2021-01-12 Thread Martin Kepplinger
From: Guido Günther 

This is consistent with other IRQs and makes keeps currents low.

Signed-off-by: Guido Günther 
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index f85d30a0c2cb..9928e941ee21 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -276,7 +276,7 @@
pinctrl_charger_in: chargeringrp {
fsl,pins = <
/* CHRG_INT */
-   MX8MQ_IOMUXC_NAND_CE2_B_GPIO3_IO3   0x00
+   MX8MQ_IOMUXC_NAND_CE2_B_GPIO3_IO3   0x80
/* CHG_STATUS_B */
MX8MQ_IOMUXC_NAND_ALE_GPIO3_IO0 0x80
>;
-- 
2.20.1



[PATCH v2 3/3] scsi: sd: Documentation: describe ignore_resume_medium_changed

2021-01-12 Thread Martin Kepplinger
Add notes about the new sd sysfs knob that works around problems
with runtime PM for certain types of SD cardreaders.

Signed-off-by: Martin Kepplinger 
---
 Documentation/scsi/sd-parameters.rst | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/scsi/sd-parameters.rst 
b/Documentation/scsi/sd-parameters.rst
index 87d554008bfb..a77b9fdffddf 100644
--- a/Documentation/scsi/sd-parameters.rst
+++ b/Documentation/scsi/sd-parameters.rst
@@ -25,3 +25,17 @@ To modify the caching mode without making the change 
persistent, prepend
 "temporary " to the cache type string. E.g.::
 
   # echo "temporary write back" > cache_type
+
+ignore_resume_medium_changed (RW)
+-
+Some SD cardreaders deliver a "media changed" unit attention (that results
+in I/O error) when they are resumed from suspend. This prevents users
+to use runtime PM with these devices. To enable runtime PM for an SD
+cardreader (here, device number 0:0:0:0), do something like:
+
+echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
+echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
+echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control
+
+And if using the mounted disk filesystem causes trouble, try setting
+ignore_resume_medium_changed to 1.
-- 
2.20.1



[PATCH v2 0/3] scsi: add runtime PM workaround for SD cardreaders

2021-01-12 Thread Martin Kepplinger
revision history

v2:
 * move module parameter to sd
 * add Documentation

v1:
https://lore.kernel.org/linux-scsi/2021052029.28426-1-martin.kepplin...@puri.sm/T/#t



hi,

In short: there are SD cardreaders that send MEDIA_CHANGED on
runtime resume. We cannot use runtime PM with these devices as
I/O basically always fails. I'd like to discuss a way to fix this
or at least allow users to work around this problem:

For the full background, the discussion started in June 2020 here:
https://lore.kernel.org/linux-scsi/20200623111018.31954-1-martin.kepplin...@puri.sm/

and I sent the first of these patches in August, as a reference:
https://lore.kernel.org/linux-scsi/20200824190400.12339-1-martin.kepplin...@puri.sm/
so this is where I'm following up on.

I'm not sure whether maintaining an in-kernel quirk for specific devices
makes sense so here I suggest adding a userspace knob. This way there's at
least a chance to use runtime PM for sd cardreaders that send MEDIA_CHANGED.

I'd appreciate any feedback.

Martin Kepplinger (3):
  scsi: add expecting_media_change flag to error path
  scsi: sd: add ignore_resume_medium_changed disk setting
  scsi: sd: Documentation: describe ignore_resume_medium_changed

 Documentation/scsi/sd-parameters.rst | 14 
 drivers/scsi/scsi_error.c| 36 +---
 drivers/scsi/sd.c| 50 +++-
 drivers/scsi/sd.h|  1 +
 include/scsi/scsi_device.h   |  1 +
 5 files changed, 96 insertions(+), 6 deletions(-)

-- 
2.20.1



[PATCH v2 2/3] scsi: sd: add ignore_resume_medium_changed disk setting

2021-01-12 Thread Martin Kepplinger
Add a userspace knob for scsi disks that deliver a MEDIA CHANGED
unit attention when the device actually only resumes from (runtime) suspend.
Those devices need the new ignore_resume_medium_changed knob set to 1
in order to be able to use runtime PM.

To enable runtime PM for an SD cardreader (here, device number 0:0:0:0),
do the following:

echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control

Set ignore_resume_medium_changed to 1 if you experience this problem.
Otherwise the unit attention would trigger I/O failure like the following
when using the mounted disk:

[  167.603864] sd 0:0:0:0: [sda] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00
driverbyte=0x08 cmd_age=0s
[  167.603892] sd 0:0:0:0: [sda] tag#0 Sense Key : 0x6 [current]
[  167.603899] sd 0:0:0:0: [sda] tag#0 ASC=0x28 ASCQ=0x0
[  167.603909] sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 01 c4 08 98 00 00 
10 00
[  167.603915] blk_update_request: I/O error, dev sda, sector 29624472 op
0x1:(WRITE) flags 0x800 phys_seg 2 prio class 0
[  167.614750] Aborting journal on device sda1-8.
[  167.619460] sd 0:0:0:0: [sda] tag#0 device offline or changed
[  167.625342] blk_update_request: I/O error, dev sda, sector 29624320 op
0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
[  167.636161] Buffer I/O error on dev sda1, logical block 3702784, lost sync 
page write
[  167.644132] JBD2: Error -5 detected when updating journal superblock for 
sda1-8.

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/sd.c | 50 ++-
 drivers/scsi/sd.h |  1 +
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a3d2d4bc4a3d..14b850d2af59 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -114,6 +114,7 @@ static void sd_shutdown(struct device *);
 static int sd_suspend_system(struct device *);
 static int sd_suspend_runtime(struct device *);
 static int sd_resume(struct device *);
+static int sd_resume_runtime(struct device *);
 static void sd_rescan(struct device *);
 static blk_status_t sd_init_command(struct scsi_cmnd *SCpnt);
 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
@@ -375,6 +376,33 @@ thin_provisioning_show(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR_RO(thin_provisioning);
 
+static ssize_t
+ignore_resume_medium_changed_show(struct device *dev, struct device_attribute 
*attr, char *buf)
+{
+   struct scsi_disk *sdkp = to_scsi_disk(dev);
+
+   return sprintf(buf, "%u\n", sdkp->ignore_resume_medium_changed);
+}
+
+static ssize_t
+ignore_resume_medium_changed_store(struct device *dev, struct device_attribute 
*attr,
+   const char *buf, size_t count)
+{
+   bool v;
+   struct scsi_disk *sdkp = to_scsi_disk(dev);
+
+   if (!capable(CAP_SYS_ADMIN))
+   return -EACCES;
+
+   if (kstrtobool(buf, ))
+   return -EINVAL;
+
+   sdkp->ignore_resume_medium_changed = v;
+
+   return count;
+}
+static DEVICE_ATTR_RW(ignore_resume_medium_changed);
+
 /* sysfs_match_string() requires dense arrays */
 static const char *lbp_mode[] = {
[SD_LBP_FULL]   = "full",
@@ -591,6 +619,7 @@ static struct attribute *sd_disk_attrs[] = {
_attr_max_medium_access_timeouts.attr,
_attr_zoned_cap.attr,
_attr_max_retries.attr,
+   _attr_ignore_resume_medium_changed.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(sd_disk);
@@ -608,7 +637,7 @@ static const struct dev_pm_ops sd_pm_ops = {
.poweroff   = sd_suspend_system,
.restore= sd_resume,
.runtime_suspend= sd_suspend_runtime,
-   .runtime_resume = sd_resume,
+   .runtime_resume = sd_resume_runtime,
 };
 
 static struct scsi_driver sd_template = {
@@ -3699,6 +3728,25 @@ static int sd_resume(struct device *dev)
return ret;
 }
 
+static int sd_resume_runtime(struct device *dev)
+{
+   struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   int ret;
+
+   if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
+   return 0;
+
+   /*
+* ignore_resume_media_change is the userspace setting and
+* expecting_media_change is what is checked and cleared in the
+* error path if we set it here.
+*/
+   if (sdkp->ignore_resume_medium_changed)
+   sdkp->device->expecting_media_change = 1;
+
+   return sd_resume(dev);
+}
+
 /**
  * init_sd - entry point for this driver (both when built in or when
  * a module).
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index b59136c4125b..1b041331356c 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -125,6 +125,7 @@ struct scsi_disk {
unsignedurswrz : 1;
un

[PATCH v2 1/3] scsi: add expecting_media_change flag to error path

2021-01-12 Thread Martin Kepplinger
SD Cardreaders (especially) sometimes lose the state during suspend
and deliver a "media changed" unit attention when really only a
(runtime) suspend/resume cycle has been done.

For such devices, I/O fails when runtime PM is enabled, see below.

Add a flag for drivers to use when this is expected. It's handled in the
scsi core error path and allows to use (runtime) PM when it has
not been possible before on said hardware.

The "downside" is that we rely more on users not to really change
the medium (SD card) *during* a runtime suspend/resume, i.e. when not
unmounting.

To enable runtime PM for an SD cardreader (here, device number 0:0:0:0),
do the following:

echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_error.c  | 36 +++-
 include/scsi/scsi_device.h |  1 +
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f11f51e2465f..f3b34c142088 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -573,6 +573,18 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
return NEEDS_RETRY;
}
}
+   if (scmd->device->expecting_media_change) {
+   if (sshdr.asc == 0x28 && sshdr.ascq == 0x00) {
+   /*
+* clear the expecting_media_change in
+* scsi_decide_disposition() because we
+* need to catch possible "fail fast" overrides
+* that block readahead can cause.
+*/
+   return NEEDS_RETRY;
+   }
+   }
+
/*
 * we might also expect a cc/ua if another LUN on the target
 * reported a UA with an ASC/ASCQ of 3F 0E -
@@ -1959,14 +1971,28 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 * the request was not marked fast fail.  Note that above,
 * even if the request is marked fast fail, we still requeue
 * for queue congestion conditions (QUEUE_FULL or BUSY) */
-   if (scsi_cmd_retry_allowed(scmd) && !scsi_noretry_cmd(scmd)) {
-   return NEEDS_RETRY;
-   } else {
-   /*
-* no more retries - report this one back to upper level.
+   if (scsi_cmd_retry_allowed(scmd)) {
+   /* but scsi_noretry_cmd() cannot override the
+* expecting_media_change flag.
 */
+   if (!scsi_noretry_cmd(scmd) ||
+   scmd->device->expecting_media_change) {
+   scmd->device->expecting_media_change = 0;
+   return NEEDS_RETRY;
+   }
+
+   /* Not marked fail fast, or marked but not expected.
+* Clear the flag too because it's meant for the
+* next UA only.
+*/
+   scmd->device->expecting_media_change = 0;
return SUCCESS;
}
+
+   /*
+* no more retries - report this one back to upper level.
+*/
+   return SUCCESS;
 }
 
 static void eh_lock_door_done(struct request *req, blk_status_t status)
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 1a5c9a3df6d6..ca2c3eb5830f 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -170,6 +170,7 @@ struct scsi_device {
 * this device */
unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
 * because we did a bus reset. */
+   unsigned expecting_media_change:1; /* Expecting "media changed" UA */
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */
-- 
2.20.1



Re: [PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag

2021-01-11 Thread Martin Kepplinger

On 11.01.21 16:20, Martin Kepplinger wrote:

Make the sd driver act appropriately when the user has set
expect_media_change_suspend for a device.

Signed-off-by: Martin Kepplinger 
---
  drivers/scsi/sd.c | 21 -
  1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a3d2d4bc4a3d..ad89f8c76a27 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -608,7 +608,7 @@ static const struct dev_pm_ops sd_pm_ops = {
.poweroff   = sd_suspend_system,
.restore= sd_resume,
.runtime_suspend= sd_suspend_runtime,
-   .runtime_resume = sd_resume,
+   .runtime_resume = sd_resume_runtime,
  };
  
  static struct scsi_driver sd_template = {

@@ -3699,6 +3699,25 @@ static int sd_resume(struct device *dev)
return ret;
  }
  
+static int sd_resume_runtime(struct device *dev)

+{
+   struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   int ret;
+
+   if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
+   return 0;
+
+   /*
+* expect_media_change_suspend is the userspace setting and
+* expecting_media_change is what is checked and cleared in the
+* error path if we set it here.
+*/
+   if (sdkp->device->expect_media_change_suspend)
+   sdkp->device->expecting_media_change = 1;
+
+   return sd_resume(dev);
+}
+
  /**
   *init_sd - entry point for this driver (both when built in or when
   *a module).



oops, I'm very sorry, but the following is missing in order for this to 
build:


--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -114,6 +114,7 @@ static void sd_shutdown(struct device *);
 static int sd_suspend_system(struct device *);
 static int sd_suspend_runtime(struct device *);
 static int sd_resume(struct device *);
+static int sd_resume_runtime(struct device *);
 static void sd_rescan(struct device *);
 static blk_status_t sd_init_command(struct scsi_cmnd *SCpnt);
 static void sd_uninit_command(struct scsi_cmnd *SCpnt);


[PATCH 2/3] scsi: add expect_media_change_suspend sysfs device setting

2021-01-11 Thread Martin Kepplinger
Add a user-facing flag that sets expecting_media_change on runtime
resume. That works around devices that send MEDIA_CHANGED when it
actually is just resumed from suspend and the media can be expected
not to have changed.

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_sysfs.c  | 38 ++
 include/scsi/scsi_device.h |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b6378c8ca783..a049290addff 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1189,6 +1189,43 @@ static DEVICE_ATTR(queue_ramp_up_period, S_IRUGO | 
S_IWUSR,
   sdev_show_queue_ramp_up_period,
   sdev_store_queue_ramp_up_period);
 
+static ssize_t
+sdev_show_expect_media_change_suspend(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   struct scsi_device *sdev;
+   sdev = to_scsi_device(dev);
+
+   if (sdev->expect_media_change_suspend)
+   return sprintf(buf, "1\n");
+   else
+   return sprintf(buf, "0\n");
+}
+
+static ssize_t
+sdev_store_expect_media_change_suspend(struct device *dev,
+  struct device_attribute *attr,
+  const char *buf, size_t count)
+{
+   struct scsi_device *sdev;
+   unsigned int flag;
+   int err;
+
+   if (!capable(CAP_SYS_ADMIN))
+   return -EACCES;
+
+   sdev = to_scsi_device(dev);
+   err = kstrtouint(buf, 10, );
+   if (err)
+   return err;
+   sdev->expect_media_change_suspend = !!flag;
+
+   return count;
+}
+static DEVICE_ATTR(expect_media_change_suspend, S_IRUGO | S_IWUSR,
+  sdev_show_expect_media_change_suspend,
+  sdev_store_expect_media_change_suspend);
+
 static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
 struct attribute *attr, int i)
 {
@@ -1260,6 +1297,7 @@ static struct attribute *scsi_sdev_attrs[] = {
_attr_queue_type.attr,
_attr_wwid.attr,
_attr_blacklist.attr,
+   _attr_expect_media_change_suspend.attr,
 #ifdef CONFIG_SCSI_DH
_attr_dh_state.attr,
_attr_access_state.attr,
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index ca2c3eb5830f..fafb8e6ea4d0 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -171,6 +171,8 @@ struct scsi_device {
unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
 * because we did a bus reset. */
unsigned expecting_media_change:1; /* Expecting "media changed" UA */
+   unsigned expect_media_change_suspend:1; /* User facing flag to enable
+* the above flag on runtime 
resume */
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */
-- 
2.20.1



[PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag

2021-01-11 Thread Martin Kepplinger
Make the sd driver act appropriately when the user has set
expect_media_change_suspend for a device.

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/sd.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a3d2d4bc4a3d..ad89f8c76a27 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -608,7 +608,7 @@ static const struct dev_pm_ops sd_pm_ops = {
.poweroff   = sd_suspend_system,
.restore= sd_resume,
.runtime_suspend= sd_suspend_runtime,
-   .runtime_resume = sd_resume,
+   .runtime_resume = sd_resume_runtime,
 };
 
 static struct scsi_driver sd_template = {
@@ -3699,6 +3699,25 @@ static int sd_resume(struct device *dev)
return ret;
 }
 
+static int sd_resume_runtime(struct device *dev)
+{
+   struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   int ret;
+
+   if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
+   return 0;
+
+   /*
+* expect_media_change_suspend is the userspace setting and
+* expecting_media_change is what is checked and cleared in the
+* error path if we set it here.
+*/
+   if (sdkp->device->expect_media_change_suspend)
+   sdkp->device->expecting_media_change = 1;
+
+   return sd_resume(dev);
+}
+
 /**
  * init_sd - entry point for this driver (both when built in or when
  * a module).
-- 
2.20.1



[PATCH 1/3] scsi: add expecting_media_change flag to error path

2021-01-11 Thread Martin Kepplinger
SD Cardreaders (especially) sometimes lose the state during suspend
and deliver a "media changed" unit attention when really only a
(runtime) suspend/resume cycle has been done.

For such devices, I/O fails when runtime PM is enabled, see below.

Add a flag for drivers to use when this is expected. It's handled in the
scsi core error path and allows to use (runtime) PM when it has
not been possible before on said hardware.

The "downside" is that we rely more on users not to really change
the medium (SD card) *during* a runtime suspend/resume, i.e. when not
unmounting.

To enable runtime PM for an SD cardreader (here, device number 0:0:0:0),
do the following:

echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control

Signed-off-by: Martin Kepplinger 
---
 drivers/scsi/scsi_error.c  | 36 +++-
 include/scsi/scsi_device.h |  1 +
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f11f51e2465f..f3b34c142088 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -573,6 +573,18 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
return NEEDS_RETRY;
}
}
+   if (scmd->device->expecting_media_change) {
+   if (sshdr.asc == 0x28 && sshdr.ascq == 0x00) {
+   /*
+* clear the expecting_media_change in
+* scsi_decide_disposition() because we
+* need to catch possible "fail fast" overrides
+* that block readahead can cause.
+*/
+   return NEEDS_RETRY;
+   }
+   }
+
/*
 * we might also expect a cc/ua if another LUN on the target
 * reported a UA with an ASC/ASCQ of 3F 0E -
@@ -1959,14 +1971,28 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 * the request was not marked fast fail.  Note that above,
 * even if the request is marked fast fail, we still requeue
 * for queue congestion conditions (QUEUE_FULL or BUSY) */
-   if (scsi_cmd_retry_allowed(scmd) && !scsi_noretry_cmd(scmd)) {
-   return NEEDS_RETRY;
-   } else {
-   /*
-* no more retries - report this one back to upper level.
+   if (scsi_cmd_retry_allowed(scmd)) {
+   /* but scsi_noretry_cmd() cannot override the
+* expecting_media_change flag.
 */
+   if (!scsi_noretry_cmd(scmd) ||
+   scmd->device->expecting_media_change) {
+   scmd->device->expecting_media_change = 0;
+   return NEEDS_RETRY;
+   }
+
+   /* Not marked fail fast, or marked but not expected.
+* Clear the flag too because it's meant for the
+* next UA only.
+*/
+   scmd->device->expecting_media_change = 0;
return SUCCESS;
}
+
+   /*
+* no more retries - report this one back to upper level.
+*/
+   return SUCCESS;
 }
 
 static void eh_lock_door_done(struct request *req, blk_status_t status)
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 1a5c9a3df6d6..ca2c3eb5830f 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -170,6 +170,7 @@ struct scsi_device {
 * this device */
unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
 * because we did a bus reset. */
+   unsigned expecting_media_change:1; /* Expecting "media changed" UA */
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */
-- 
2.20.1



[PATCH 0/3] scsi: add runtime PM workaround for SD cardreaders

2021-01-11 Thread Martin Kepplinger
hi,

In short: there are SD cardreaders that send MEDIA_CHANGED on
runtime resume. We cannot use runtime PM with these devices as
I/O basically always fails. I'd like to discuss a way to fix this
or at least allow users to work around this problem:

For the full background, the discussion started in June 2020 here:
https://lore.kernel.org/linux-scsi/20200623111018.31954-1-martin.kepplin...@puri.sm/

and I sent the first of these patches in August, as a reference:
https://lore.kernel.org/linux-scsi/20200824190400.12339-1-martin.kepplin...@puri.sm/
so this is where I'm following up on.

I'm not sure whether maintaining an in-kernel quirk for specific devices
makes sense so here I suggest adding a userspace setting. Of course we should
document it properly if this makes sense to you. But this way there's at least
a chance to use runtime PM for sd cardreaders that send MEDIA_CHANGED.

Questions would be:
* Do you like the approach of a user+internal flag?
* what to do in scsi drivers that ignore the flag? Is documentation enough?
* review the *clearing* of the (internal) flag once again. the first
  occurrence of MEDIA_CHANGED should do that only. (note to myself)

I'd appreciate any feedback.


Martin Kepplinger (3):
  scsi: add expecting_media_change flag to error path
  scsi: add expect_media_change_suspend sysfs device setting
  scsi: sd: add support for expect_media_change_suspend flag

 drivers/scsi/scsi_error.c  | 36 +++-
 drivers/scsi/scsi_sysfs.c  | 38 ++
 drivers/scsi/sd.c  | 21 -
 include/scsi/scsi_device.h |  3 +++
 4 files changed, 92 insertions(+), 6 deletions(-)

-- 
2.20.1



Re: [PATCH v2 2/4] arm64: dts: imx8mq-librem5: add pinctrl for the touchscreen description

2021-01-11 Thread Martin Kepplinger

On 11.01.21 01:29, Shawn Guo wrote:

On Tue, Dec 22, 2020 at 04:13:45PM +0100, Martin Kepplinger wrote:

In order for the touchscreen interrupt line to work, describe it properly.
Otherwise it can work if defaults are ok, but we cannot be sure.

Fixes: 8f0216b006e5 ("arm64: dts: Add a device tree for the Librem 5 phone")
Signed-off-by: Martin Kepplinger 
---
  arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 9 +
  1 file changed, 9 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 55268fc0622e..a60df09d90f7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -459,6 +459,13 @@
>;
};
  
+	pinctrl_touch: touchgrp {

+   fsl,pins = <
+   /* TP_INT */
+   MX8MQ_IOMUXC_ENET_RD1_GPIO1_IO270x80


Miss indentation for these two lines.

I fixed it up and applied the series.

Shawn



thanks for this!

martin


[PATCH v4 3/5] dt-bindings: mxsfb: Add interconnect bindings for LCDIF path

2021-01-11 Thread Martin Kepplinger
Add optional interconnect properties for the dram path requests.

Signed-off-by: Martin Kepplinger 
---
 Documentation/devicetree/bindings/display/mxsfb.txt | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/mxsfb.txt 
b/Documentation/devicetree/bindings/display/mxsfb.txt
index c985871c46b3..d494a2674290 100644
--- a/Documentation/devicetree/bindings/display/mxsfb.txt
+++ b/Documentation/devicetree/bindings/display/mxsfb.txt
@@ -15,6 +15,12 @@ Required properties:
 - "pix" for the LCDIF block clock
 - (MX6SX-only) "axi", "disp_axi" for the bus interface clock
 
+Optional properties:
+- interconnects : interconnect path specifier for LCDIF according to
+   Documentation/devicetree/bindings/interconnect/interconnect.txt.
+- interconnect-names: the name describing the interconnect path.
+   Should be "dram" for i.MX8MQ.
+
 Required sub-nodes:
   - port: The connection to an encoder chip.
 
-- 
2.20.1



[PATCH v4 2/5] arm64: dts: imx8mq: Add interconnect provider property

2021-01-11 Thread Martin Kepplinger
Add #interconnect-cells on main  so that it will probe the interconnect
provider.

Signed-off-by: Martin Kepplinger 
Acked-by: Georgi Djakov 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index dbe480a76aa1..89e7de2e7f7a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1163,6 +1163,7 @@
reg = <0x3270 0x10>;
clocks = < IMX8MQ_CLK_NOC>;
fsl,ddrc = <>;
+   #interconnect-cells = <1>;
operating-points-v2 = <_opp_table>;
 
noc_opp_table: opp-table {
-- 
2.20.1



Re: [PATCH v4 0/5] imx8mq: updates for the interconnect fabric

2021-01-10 Thread Martin Kepplinger

On 11.01.21 05:51, Shawn Guo wrote:

On Thu, Jan 07, 2021 at 01:17:49PM +0100, Martin Kepplinger wrote:

revision history:
v4: (thanks Shawn, Georgi and Greg)
  * reorder to have dt-bindings doc before code addition
  * add newline between dt nodes
  * removed "interconnect: imx8mq: Use icc_sync_state" from the patchset
since it's part of gregkh/char-misc.git
  * Add acks

v3: (thanks Krysztof and Georgi)
  * drop the defconfig cycling patch and fix the interconnect enable config
  * add the noc node to imx8mq only
  * add missing signed-off-by
  * 
https://lore.kernel.org/linux-arm-kernel/20201210100906.18205-1-martin.kepplin...@puri.sm/T/#t

v2: (thanks Lucas)
  * reorder and clean up defconfig changes
  * use "dram" for the interconnect path name and document it
  * 
https://lore.kernel.org/linux-arm-kernel/20201201123932.12312-1-martin.kepplin...@puri.sm/T/#t

v1:
  * 
https://lore.kernel.org/linux-arm-kernel/20201201100124.4676-1-martin.kepplin...@puri.sm/T/#t

thanks,
 martin


Leonard Crestez (1):
   arm64: dts: imx8mq: Add NOC node

Martin Kepplinger (4):
   arm64: dts: imx8mq: Add interconnect provider property
   dt-bindings: mxsfb: Add interconnect bindings for LCDIF path
   arm64: dts: imx8mq: Add interconnect for lcdif
   arm64: defconfig: Enable interconnect for imx8mq


I only received 3 patches, 1/5, 4/5 and 5/5.

Shawn



strange as they made it to the lists, see 
https://lore.kernel.org/linux-arm-kernel/20210107121754.3295-1-martin.kepplin...@puri.sm/ 
but I can resend into this thread.


 martin


Re: [PATCH] Revert "clk: imx: fix composite peripheral flags"

2021-01-07 Thread Martin Kepplinger

On 04.01.21 13:05, Abel Vesa wrote:

On 20-12-31 17:33:40, Fabio Estevam wrote:

Hi Martin,

On Thu, Dec 31, 2020 at 11:22 AM Martin Kepplinger
 wrote:


This reverts commit 936c383673b9e3007432f17140ac62de53d87db9.

It breaks clock reparenting via devfreq on the imx8mq used in the
Librem 5 phone. When switching dram frequency (which worked before)
the system now hangs after this where the dram_apb clock cannot be
set:

[  129.391755] imx8m-ddrc-devfreq 3d40.memory-controller: failed to
set dram_apb parent: -16
[  129.391959] imx8m-ddrc-devfreq 3d40.memory-controller: ddrc
failed freq switch to 2500 from 8: error -16. now at 2500
[  129.406133] imx8m-ddrc-devfreq 3d40.memory-controller: failed to
update frequency from PM QoS (-16)


I am wondering whether IMX8MQ_CLK_DRAM_ALT should also be marked as
CLK_IS_CRITICAL.



Hmm, the way the DRAM clocks are right registered right now is a real mess.
The DRAM clocks on i.MX8M are changed in TF-A, but the kernel still needs to
register them to keep track of the clock tree.

Martin, I already have a patchset waiting to be shipped which doesn't
only fix the 8MQ, but all the 8M platforms. Unfortunately, I haven't had the 
time
to work on that in the last couple of weeks but I intend to switch back to it 
soon.

Fabio, marking the DRAM clocks as critical will not allow the set_parent to be 
done,
as CLK_IS_CRITICAL flag and set_parent do not go together. As of now the devfreq
tries to reparent to be consistent with TF-A configuration.

My approach here was to make the DRAM clocks read-only. This means adding some
stuff in the clock core subsystem too.


Hi Abel, thanks a lot for the update. I'm looking forward to seeing your 
patchset.


  martin


[PATCH v4 5/5] arm64: defconfig: Enable interconnect for imx8mq

2021-01-07 Thread Martin Kepplinger
Enable INTERCONNECT_IMX8MQ in order to make interconnect more widely
available.

Signed-off-by: Martin Kepplinger 
Acked-by: Georgi Djakov 
---
 arch/arm64/configs/defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 3ca9d03d5cb3..0095df536f74 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1078,6 +1078,8 @@ CONFIG_SLIM_QCOM_CTRL=m
 CONFIG_SLIM_QCOM_NGD_CTRL=m
 CONFIG_MUX_MMIO=y
 CONFIG_INTERCONNECT=y
+CONFIG_INTERCONNECT_IMX=m
+CONFIG_INTERCONNECT_IMX8MQ=m
 CONFIG_INTERCONNECT_QCOM=y
 CONFIG_INTERCONNECT_QCOM_MSM8916=m
 CONFIG_INTERCONNECT_QCOM_OSM_L3=m
-- 
2.20.1



[PATCH v4 4/5] arm64: dts: imx8mq: Add interconnect for lcdif

2021-01-07 Thread Martin Kepplinger
Add interconnect ports for lcdif to set bus capabilities.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 89e7de2e7f7a..9300be8c9b53 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -11,6 +11,7 @@
 #include "dt-bindings/input/input.h"
 #include 
 #include 
+#include 
 #include "imx8mq-pinfunc.h"
 
 / {
@@ -522,6 +523,8 @@
  < IMX8MQ_VIDEO_PLL1>,
  < IMX8MQ_VIDEO_PLL1_OUT>;
assigned-clock-rates = <0>, <0>, <0>, 
<59400>;
+   interconnects = < IMX8MQ_ICM_LCDIF  
IMX8MQ_ICS_DRAM>;
+   interconnect-names = "dram";
status = "disabled";
 
port@0 {
-- 
2.20.1



[PATCH v4 0/5] imx8mq: updates for the interconnect fabric

2021-01-07 Thread Martin Kepplinger
revision history:
v4: (thanks Shawn, Georgi and Greg)
 * reorder to have dt-bindings doc before code addition
 * add newline between dt nodes
 * removed "interconnect: imx8mq: Use icc_sync_state" from the patchset
   since it's part of gregkh/char-misc.git
 * Add acks

v3: (thanks Krysztof and Georgi)
 * drop the defconfig cycling patch and fix the interconnect enable config
 * add the noc node to imx8mq only
 * add missing signed-off-by
 * 
https://lore.kernel.org/linux-arm-kernel/20201210100906.18205-1-martin.kepplin...@puri.sm/T/#t

v2: (thanks Lucas)
 * reorder and clean up defconfig changes
 * use "dram" for the interconnect path name and document it
 * 
https://lore.kernel.org/linux-arm-kernel/20201201123932.12312-1-martin.kepplin...@puri.sm/T/#t

v1:
 * 
https://lore.kernel.org/linux-arm-kernel/20201201100124.4676-1-martin.kepplin...@puri.sm/T/#t

thanks,
martin


Leonard Crestez (1):
  arm64: dts: imx8mq: Add NOC node

Martin Kepplinger (4):
  arm64: dts: imx8mq: Add interconnect provider property
  dt-bindings: mxsfb: Add interconnect bindings for LCDIF path
  arm64: dts: imx8mq: Add interconnect for lcdif
  arm64: defconfig: Enable interconnect for imx8mq

 .../devicetree/bindings/display/mxsfb.txt |  6 
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 28 +++
 arch/arm64/configs/defconfig  |  2 ++
 3 files changed, 36 insertions(+)

-- 
2.20.1



[PATCH v4 3/5] dt-bindings: mxsfb: Add interconnect bindings for LCDIF path

2021-01-07 Thread Martin Kepplinger
Add optional interconnect properties for the dram path requests.

Signed-off-by: Martin Kepplinger 
---
 Documentation/devicetree/bindings/display/mxsfb.txt | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/mxsfb.txt 
b/Documentation/devicetree/bindings/display/mxsfb.txt
index c985871c46b3..d494a2674290 100644
--- a/Documentation/devicetree/bindings/display/mxsfb.txt
+++ b/Documentation/devicetree/bindings/display/mxsfb.txt
@@ -15,6 +15,12 @@ Required properties:
 - "pix" for the LCDIF block clock
 - (MX6SX-only) "axi", "disp_axi" for the bus interface clock
 
+Optional properties:
+- interconnects : interconnect path specifier for LCDIF according to
+   Documentation/devicetree/bindings/interconnect/interconnect.txt.
+- interconnect-names: the name describing the interconnect path.
+   Should be "dram" for i.MX8MQ.
+
 Required sub-nodes:
   - port: The connection to an encoder chip.
 
-- 
2.20.1



[PATCH v4 2/5] arm64: dts: imx8mq: Add interconnect provider property

2021-01-07 Thread Martin Kepplinger
Add #interconnect-cells on main  so that it will probe the interconnect
provider.

Signed-off-by: Martin Kepplinger 
Acked-by: Georgi Djakov 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index dbe480a76aa1..89e7de2e7f7a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1163,6 +1163,7 @@
reg = <0x3270 0x10>;
clocks = < IMX8MQ_CLK_NOC>;
fsl,ddrc = <>;
+   #interconnect-cells = <1>;
operating-points-v2 = <_opp_table>;
 
noc_opp_table: opp-table {
-- 
2.20.1



[PATCH v4 1/5] arm64: dts: imx8mq: Add NOC node

2021-01-07 Thread Martin Kepplinger
From: Leonard Crestez 

Add initial support for dynamic frequency scaling of the main NOC
on imx8mq.

Make DDRC the parent of the NOC (using passive governor) so that the
main NOC is automatically scaled together with DDRC by default.

Support for proactive scaling via interconnect will come on top.

Signed-off-by: Leonard Crestez 
Signed-off-by: Martin Kepplinger 
Acked-by: Georgi Djakov 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index a841a023e8e0..dbe480a76aa1 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1158,6 +1158,30 @@
};
};
 
+   noc: interconnect@3270 {
+   compatible = "fsl,imx8mq-noc", "fsl,imx8m-noc";
+   reg = <0x3270 0x10>;
+   clocks = < IMX8MQ_CLK_NOC>;
+   fsl,ddrc = <>;
+   operating-points-v2 = <_opp_table>;
+
+   noc_opp_table: opp-table {
+   compatible = "operating-points-v2";
+
+   opp-133M {
+   opp-hz = /bits/ 64 <1>;
+   };
+
+   opp-400M {
+   opp-hz = /bits/ 64 <4>;
+   };
+
+   opp-800M {
+   opp-hz = /bits/ 64 <8>;
+   };
+   };
+   };
+
bus@32c0 { /* AIPS4 */
compatible = "fsl,aips-bus", "simple-bus";
reg = <0x32c0 0x40>;
-- 
2.20.1



[PATCH] Revert "clk: imx: fix composite peripheral flags"

2020-12-31 Thread Martin Kepplinger
This reverts commit 936c383673b9e3007432f17140ac62de53d87db9.

It breaks clock reparenting via devfreq on the imx8mq used in the
Librem 5 phone. When switching dram frequency (which worked before)
the system now hangs after this where the dram_apb clock cannot be
set:

[  129.391755] imx8m-ddrc-devfreq 3d40.memory-controller: failed to
set dram_apb parent: -16
[  129.391959] imx8m-ddrc-devfreq 3d40.memory-controller: ddrc
failed freq switch to 2500 from 8: error -16. now at 2500
[  129.406133] imx8m-ddrc-devfreq 3d40.memory-controller: failed to
update frequency from PM QoS (-16)

Note that on the Librem 5 devkit that uses a different revision of the
imx8mq SoC, the added flag does *not* break said clock reparenting so
there might be subtle differences here.

Signed-off-by: Martin Kepplinger 
---
 drivers/clk/imx/clk-composite-8m.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/imx/clk-composite-8m.c 
b/drivers/clk/imx/clk-composite-8m.c
index 2c309e3dc8e3..78fb7e52a42a 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -216,7 +216,6 @@ struct clk_hw *imx8m_clk_hw_composite_flags(const char 
*name,
div->width = PCG_PREDIV_WIDTH;
divider_ops = _clk_composite_divider_ops;
mux_ops = _mux_ops;
-   flags |= CLK_SET_PARENT_GATE;
}
 
div->lock = _ccm_lock;
-- 
2.20.1



[PATCH v2 1/4] arm64: dts: imx8mq-librem5: add vin-supply to VDD_1V8

2020-12-22 Thread Martin Kepplinger
buck7 is the supply here. Also, fix alphabetical ordering.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 64fc546b110f..55268fc0622e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -99,6 +99,14 @@
regulator-max-microvolt = <330>;
};
 
+   reg_vdd_1v8: regulator-vdd-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_reg>;
+   };
+
reg_vdd_3v3: regulator-vdd-3v3 {
compatible = "regulator-fixed";
regulator-name = "VDD_3V3";
@@ -106,13 +114,6 @@
regulator-max-microvolt = <330>;
};
 
-   reg_vdd_1v8: regulator-vdd-1v8 {
-   compatible = "regulator-fixed";
-   regulator-name = "VCC_1V8";
-   regulator-min-microvolt = <180>;
-   regulator-max-microvolt = <180>;
-   };
-
reg_vsys_3v4: regulator-vsys-3v4 {
compatible = "regulator-fixed";
regulator-name = "VSYS_3V4";
-- 
2.20.1



[PATCH v2 4/4] arm64: dts: imx8mq-librem5-r3: workaround i2c1 issue with 1GHz cpu voltage

2020-12-22 Thread Martin Kepplinger
This is a workaround for a hardware bug in the r3 revision that basically would
stop the system due to traffic on the i2c1 bus. A cpu voltage change would
trigger such traffic and that's what is avoided in order to work around it.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
index 6704ea2c72a3..0d38327043f8 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
@@ -10,6 +10,12 @@
compatible = "purism,librem5r3", "purism,librem5", "fsl,imx8mq";
 };
 
+_opp_table {
+   opp-10 {
+   opp-microvolt = <100>;
+   };
+};
+
 _gyro {
mount-matrix =  "1",  "0",  "0",
"0",  "1",  "0",
-- 
2.20.1



[PATCH v2 3/4] arm64: dts: imx8mq-librem5: Move usdhc clocks assignment to board DT

2020-12-22 Thread Martin Kepplinger
According to commit e045f044e84e ("arm64: dts: imx8mq: Move usdhc clocks
assignment to board DT") add the clocks assignment to imx8mq-librem5.dtsi
too.

Fixes: e045f044e84e ("arm64: dts: imx8mq: Move usdhc clocks assignment to board 
DT")
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index a60df09d90f7..47e70ba4e4f1 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1082,6 +1082,8 @@
 };
 
  {
+   assigned-clocks = < IMX8MQ_CLK_USDHC1>;
+   assigned-clock-rates = <4>;
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <_usdhc1>;
pinctrl-1 = <_usdhc1_100mhz>;
@@ -1094,6 +1096,8 @@
 };
 
  {
+   assigned-clocks = < IMX8MQ_CLK_USDHC2>;
+   assigned-clock-rates = <2>;
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <_usdhc2>;
pinctrl-1 = <_usdhc2_100mhz>;
-- 
2.20.1



[PATCH v2 0/4] small Librem 5 phone dts updates

2020-12-22 Thread Martin Kepplinger
revision history

v2: (thanks Krzysztof)
 add Fixes tags and improve commit messages
v1:
 
https://lore.kernel.org/linux-arm-kernel/20201218103131.22013-1-martin.kepplin...@puri.sm/

Martin Kepplinger (4):
  arm64: dts: imx8mq-librem5: add vin-supply to VDD_1V8
  arm64: dts: imx8mq-librem5: add pinctrl for the touchscreen
description
  arm64: dts: imx8mq-librem5: Move usdhc clocks assignment to board DT
  arm64: dts: imx8mq-librem5-r3: workaround i2c1 issue with 1GHz cpu
voltage

 .../boot/dts/freescale/imx8mq-librem5-r3.dts  |  6 
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 28 ++-
 2 files changed, 27 insertions(+), 7 deletions(-)

-- 
2.20.1



[PATCH v2 2/4] arm64: dts: imx8mq-librem5: add pinctrl for the touchscreen description

2020-12-22 Thread Martin Kepplinger
In order for the touchscreen interrupt line to work, describe it properly.
Otherwise it can work if defaults are ok, but we cannot be sure.

Fixes: 8f0216b006e5 ("arm64: dts: Add a device tree for the Librem 5 phone")
Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 55268fc0622e..a60df09d90f7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -459,6 +459,13 @@
>;
};
 
+   pinctrl_touch: touchgrp {
+   fsl,pins = <
+   /* TP_INT */
+   MX8MQ_IOMUXC_ENET_RD1_GPIO1_IO270x80
+   >;
+   };
+
pinctrl_typec: typecgrp {
fsl,pins = <
/* TYPEC_MUX_EN */
@@ -880,6 +887,8 @@
touchscreen@38 {
compatible = "edt,edt-ft5506";
reg = <0x38>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_touch>;
interrupt-parent = <>;
interrupts = <27 IRQ_TYPE_EDGE_FALLING>;
touchscreen-size-x = <720>;
-- 
2.20.1



[PATCH 3/4] arm64: dts: imx8mq-librem5: Move usdhc clocks assignment to board DT

2020-12-18 Thread Martin Kepplinger
According to commit e045f044e84e ("arm64: dts: imx8mq: Move usdhc clocks
assignment to board DT") add the clocks assignment to imx8mq-librem5.dtsi
too.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index a60df09d90f7..47e70ba4e4f1 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1082,6 +1082,8 @@
 };
 
  {
+   assigned-clocks = < IMX8MQ_CLK_USDHC1>;
+   assigned-clock-rates = <4>;
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <_usdhc1>;
pinctrl-1 = <_usdhc1_100mhz>;
@@ -1094,6 +1096,8 @@
 };
 
  {
+   assigned-clocks = < IMX8MQ_CLK_USDHC2>;
+   assigned-clock-rates = <2>;
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <_usdhc2>;
pinctrl-1 = <_usdhc2_100mhz>;
-- 
2.20.1



[PATCH 0/4] small Librem 5 phone dts updates

2020-12-18 Thread Martin Kepplinger
Some minor updates for the current hardware descriptions:

Martin Kepplinger (4):
  arm64: dts: imx8mq-librem5: add vin-supply to VDD_1V8
  arm64: dts: imx8mq-librem5: add pinctrl for the touchscreen
description
  arm64: dts: imx8mq-librem5: Move usdhc clocks assignment to board DT
  arm64: dts: imx8mq-librem5-r3: workaround i2c1 issue with 1GHz cpu
voltage

 .../boot/dts/freescale/imx8mq-librem5-r3.dts  |  6 
 .../boot/dts/freescale/imx8mq-librem5.dtsi| 28 ++-
 2 files changed, 27 insertions(+), 7 deletions(-)

-- 
2.20.1



[PATCH 4/4] arm64: dts: imx8mq-librem5-r3: workaround i2c1 issue with 1GHz cpu voltage

2020-12-18 Thread Martin Kepplinger
This is a workaround for a hardware bug in the r3 revision that basically would
stop the system due to traffic on the i2c1 bus. A cpu voltage change would
trigger such traffic and that's what is avoided in order to work around it.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
index 6704ea2c72a3..0d38327043f8 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
@@ -10,6 +10,12 @@
compatible = "purism,librem5r3", "purism,librem5", "fsl,imx8mq";
 };
 
+_opp_table {
+   opp-10 {
+   opp-microvolt = <100>;
+   };
+};
+
 _gyro {
mount-matrix =  "1",  "0",  "0",
"0",  "1",  "0",
-- 
2.20.1



[PATCH 2/4] arm64: dts: imx8mq-librem5: add pinctrl for the touchscreen description

2020-12-18 Thread Martin Kepplinger
Add the pinctrl description for the interrupt.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 55268fc0622e..a60df09d90f7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -459,6 +459,13 @@
>;
};
 
+   pinctrl_touch: touchgrp {
+   fsl,pins = <
+   /* TP_INT */
+   MX8MQ_IOMUXC_ENET_RD1_GPIO1_IO270x80
+   >;
+   };
+
pinctrl_typec: typecgrp {
fsl,pins = <
/* TYPEC_MUX_EN */
@@ -880,6 +887,8 @@
touchscreen@38 {
compatible = "edt,edt-ft5506";
reg = <0x38>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_touch>;
interrupt-parent = <>;
interrupts = <27 IRQ_TYPE_EDGE_FALLING>;
touchscreen-size-x = <720>;
-- 
2.20.1



[PATCH 1/4] arm64: dts: imx8mq-librem5: add vin-supply to VDD_1V8

2020-12-18 Thread Martin Kepplinger
buck7 is the supply here. Also, fix alphabetical ordering.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 64fc546b110f..55268fc0622e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -99,6 +99,14 @@
regulator-max-microvolt = <330>;
};
 
+   reg_vdd_1v8: regulator-vdd-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_reg>;
+   };
+
reg_vdd_3v3: regulator-vdd-3v3 {
compatible = "regulator-fixed";
regulator-name = "VDD_3V3";
@@ -106,13 +114,6 @@
regulator-max-microvolt = <330>;
};
 
-   reg_vdd_1v8: regulator-vdd-1v8 {
-   compatible = "regulator-fixed";
-   regulator-name = "VCC_1V8";
-   regulator-min-microvolt = <180>;
-   regulator-max-microvolt = <180>;
-   };
-
reg_vsys_3v4: regulator-vsys-3v4 {
compatible = "regulator-fixed";
regulator-name = "VSYS_3V4";
-- 
2.20.1



[PATCH v3 3/6] arm64: dts: imx8mq: Add interconnect for lcdif

2020-12-10 Thread Martin Kepplinger
Add interconnect ports for lcdif to set bus capabilities.

Signed-off-by: Martin Kepplinger 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 3617b7238952..7c4b68bda6fa 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -11,6 +11,7 @@
 #include "dt-bindings/input/input.h"
 #include 
 #include 
+#include 
 #include "imx8mq-pinfunc.h"
 
 / {
@@ -522,6 +523,8 @@
  < IMX8MQ_VIDEO_PLL1>,
  < IMX8MQ_VIDEO_PLL1_OUT>;
assigned-clock-rates = <0>, <0>, <0>, 
<59400>;
+   interconnects = < IMX8MQ_ICM_LCDIF  
IMX8MQ_ICS_DRAM>;
+   interconnect-names = "dram";
status = "disabled";
 
port@0 {
-- 
2.20.1



  1   2   3   4   5   6   7   8   9   10   >