Re: [Patch v5 12/12] Documention: v4l: Documentation for HEVC CIDs
Hi, Please find my comments inline. On 19 June 2017 at 07:10, Smitha T Murthywrote: > Added V4l2 controls for HEVC encoder > > Signed-off-by: Smitha T Murthy > --- > Documentation/media/uapi/v4l/extended-controls.rst | 364 > + > 1 file changed, 364 insertions(+) > > diff --git a/Documentation/media/uapi/v4l/extended-controls.rst > b/Documentation/media/uapi/v4l/extended-controls.rst > index abb1057..7767c70 100644 > --- a/Documentation/media/uapi/v4l/extended-controls.rst > +++ b/Documentation/media/uapi/v4l/extended-controls.rst > @@ -1960,6 +1960,370 @@ enum v4l2_vp8_golden_frame_sel - > 1, 2 and 3 corresponding to encoder profiles 0, 1, 2 and 3. > > [snip] > + > + > +``V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER (integer)`` > +Selects the hierarchical coding layer. In normal encoding > +(non-hierarchial coding), it should be zero. Possible values are 0 ~ 6. > +0 indicates HIERARCHICAL CODING LAYER 0, 1 indicates HIERARCHICAL CODING > +LAYER 1 and so on. I would like the above to be more consistent. If HIER is in the name then HIER in the description should be used as well. Aside from that, I would recommend using full HIERARCHICAL instead of HIER in the name of the control. Why? Because it is HIERARCHICAL in controls already present in V4L2, such as V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP. [snip] > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF (boolean)`` > +Indicates loop filtering. Control value 1 indicates loop filtering > +is enabled and when set to 0 indicates loop filtering is disabled. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_SLICE_BOUNDARY (boolean)`` > +Selects whether to apply the loop filter across the slice boundary or > not. > +If the value is 0, loop filter will not be applied across the slice > boundary. > +If the value is 1, loop filter will be applied across the slice boundary. Just a thought. Pretty much the same fucntionality is achieved via the V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE control. It's an enum having three states: enabled, disabled and disabled at slice boundary. Maybe a single control could be introduced? With another legacy define for API compatibility. Also, I don't like that controls are not consistent between H264 and HEVC. I would opt for the enum option. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2 (integer)`` > +Selects HEVC loop filter beta offset. The valid range is [-6, +6]. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2 (integer)`` > +Selects HEVC loop filter tc offset. The valid range is [-6, +6]. > + > +.. _v4l2-hevc-refresh-type: > + > +``V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE`` > +(enum) > + [snip] Best wishes, Kamil
Re: [Patch v5 12/12] Documention: v4l: Documentation for HEVC CIDs
Hi, Please find my comments inline. On 19 June 2017 at 07:10, Smitha T Murthy wrote: > Added V4l2 controls for HEVC encoder > > Signed-off-by: Smitha T Murthy > --- > Documentation/media/uapi/v4l/extended-controls.rst | 364 > + > 1 file changed, 364 insertions(+) > > diff --git a/Documentation/media/uapi/v4l/extended-controls.rst > b/Documentation/media/uapi/v4l/extended-controls.rst > index abb1057..7767c70 100644 > --- a/Documentation/media/uapi/v4l/extended-controls.rst > +++ b/Documentation/media/uapi/v4l/extended-controls.rst > @@ -1960,6 +1960,370 @@ enum v4l2_vp8_golden_frame_sel - > 1, 2 and 3 corresponding to encoder profiles 0, 1, 2 and 3. > > [snip] > + > + > +``V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER (integer)`` > +Selects the hierarchical coding layer. In normal encoding > +(non-hierarchial coding), it should be zero. Possible values are 0 ~ 6. > +0 indicates HIERARCHICAL CODING LAYER 0, 1 indicates HIERARCHICAL CODING > +LAYER 1 and so on. I would like the above to be more consistent. If HIER is in the name then HIER in the description should be used as well. Aside from that, I would recommend using full HIERARCHICAL instead of HIER in the name of the control. Why? Because it is HIERARCHICAL in controls already present in V4L2, such as V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP. [snip] > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF (boolean)`` > +Indicates loop filtering. Control value 1 indicates loop filtering > +is enabled and when set to 0 indicates loop filtering is disabled. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_SLICE_BOUNDARY (boolean)`` > +Selects whether to apply the loop filter across the slice boundary or > not. > +If the value is 0, loop filter will not be applied across the slice > boundary. > +If the value is 1, loop filter will be applied across the slice boundary. Just a thought. Pretty much the same fucntionality is achieved via the V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE control. It's an enum having three states: enabled, disabled and disabled at slice boundary. Maybe a single control could be introduced? With another legacy define for API compatibility. Also, I don't like that controls are not consistent between H264 and HEVC. I would opt for the enum option. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2 (integer)`` > +Selects HEVC loop filter beta offset. The valid range is [-6, +6]. > + > +``V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2 (integer)`` > +Selects HEVC loop filter tc offset. The valid range is [-6, +6]. > + > +.. _v4l2-hevc-refresh-type: > + > +``V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE`` > +(enum) > + [snip] Best wishes, Kamil
Re: [Patch v5 04/12] [media] s5p-mfc: Support MFCv10.10 buffer requirements
for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i)); > + buf_addr1 += ctx->luma_dpb_size; > + buf_size1 -= ctx->luma_dpb_size; > + } > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i)); > + buf_addr1 += ctx->chroma_dpb_size; > + buf_size1 -= ctx->chroma_dpb_size; > + } > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i)); > + buf_addr1 += ctx->me_buffer_size; > + buf_size1 -= ctx->me_buffer_size; > + } > + } else { > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i)); > + buf_addr1 += ctx->luma_dpb_size; > + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i)); > + buf_addr1 += ctx->chroma_dpb_size; > + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i)); > + buf_addr1 += ctx->me_buffer_size; > + buf_size1 -= (ctx->luma_dpb_size + > ctx->chroma_dpb_size > + + ctx->me_buffer_size); > + } > } > > writel(buf_addr1, mfc_regs->e_scratch_buffer_addr); > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > index 021b8db..975bbc5 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > @@ -26,6 +26,8 @@ > (((MB_HEIGHT(y)+1)/2)*2) * 64 + 128) > #define S5P_MFC_DEC_MV_SIZE_V10(x, y) (MB_WIDTH(x) * \ > (((MB_HEIGHT(y)+1)/2)*2) * 64 + 512) > +#define enc_lcu_width(x_size) DIV_ROUND_UP(x_size, 32) > +#define enc_lcu_height(y_size) DIV_ROUND_UP(y_size, 32) Why is this in lower case? Maybe S5P_MFC_LCU_WIDTH/HEIGHT would be better? > > /* Definition */ > #define ENC_MULTI_SLICE_MB_MAX ((1 << 30) - 1) > -- > 2.7.4 > Apart from the above, it looks good to me. Acked-by: Kamil Debski <ka...@wypas.org> Best wishes, Kamil Debski
Re: [Patch v5 04/12] [media] s5p-mfc: Support MFCv10.10 buffer requirements
r1, mfc_regs->e_luma_dpb + (4 * i)); > + buf_addr1 += ctx->luma_dpb_size; > + buf_size1 -= ctx->luma_dpb_size; > + } > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i)); > + buf_addr1 += ctx->chroma_dpb_size; > + buf_size1 -= ctx->chroma_dpb_size; > + } > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i)); > + buf_addr1 += ctx->me_buffer_size; > + buf_size1 -= ctx->me_buffer_size; > + } > + } else { > + for (i = 0; i < ctx->pb_count; i++) { > + writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i)); > + buf_addr1 += ctx->luma_dpb_size; > + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i)); > + buf_addr1 += ctx->chroma_dpb_size; > + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i)); > + buf_addr1 += ctx->me_buffer_size; > + buf_size1 -= (ctx->luma_dpb_size + > ctx->chroma_dpb_size > + + ctx->me_buffer_size); > + } > } > > writel(buf_addr1, mfc_regs->e_scratch_buffer_addr); > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > index 021b8db..975bbc5 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h > @@ -26,6 +26,8 @@ > (((MB_HEIGHT(y)+1)/2)*2) * 64 + 128) > #define S5P_MFC_DEC_MV_SIZE_V10(x, y) (MB_WIDTH(x) * \ > (((MB_HEIGHT(y)+1)/2)*2) * 64 + 512) > +#define enc_lcu_width(x_size) DIV_ROUND_UP(x_size, 32) > +#define enc_lcu_height(y_size) DIV_ROUND_UP(y_size, 32) Why is this in lower case? Maybe S5P_MFC_LCU_WIDTH/HEIGHT would be better? > > /* Definition */ > #define ENC_MULTI_SLICE_MB_MAX ((1 << 30) - 1) > -- > 2.7.4 > Apart from the above, it looks good to me. Acked-by: Kamil Debski Best wishes, Kamil Debski
[PATCH] MAINTAINERS: update email and list of Samsung HW driver maintainers
Change my email address in the MAINTAINERS file. Add new maintainers of selected Samsung HW drivers. Signed-off-by: Kamil Debski <k.deb...@samsung.com> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Guenter Roeck <li...@roeck-us.net> Cc: Kishon Vijay Abraham I <kis...@ti.com> Cc: Mauro Carvalho Chehab <mche...@kernel.org> Cc: linux-hw...@vger.kernel.org Cc: Andrzej Hajda <a.ha...@samsung.com> Cc: Lukasz Majewski <l.majew...@samsung.com> Cc: Sylwester Nawrocki <s.nawro...@samsung.com> Cc: Kamil Debski <ka...@wypas.org> --- MAINTAINERS | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8c20323..76e5953 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1623,7 +1623,8 @@ F:arch/arm/mach-s5pv210/ ARM/SAMSUNG S5P SERIES 2D GRAPHICS ACCELERATION (G2D) SUPPORT M: Kyungmin Park <kyungmin.p...@samsung.com> -M: Kamil Debski <k.deb...@samsung.com> +M: Kamil Debski <ka...@wypas.org> +M: Andrzej Hajda <a.ha...@samsung.com> L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -1631,8 +1632,9 @@ F:drivers/media/platform/s5p-g2d/ ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC) SUPPORT M: Kyungmin Park <kyungmin.p...@samsung.com> -M: Kamil Debski <k.deb...@samsung.com> +M: Kamil Debski <ka...@wypas.org> M: Jeongtae Park <jtp.p...@samsung.com> +M: Andrzej Hajda <a.ha...@samsung.com> L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -9241,7 +9243,8 @@ S: Maintained F: drivers/media/usb/pwc/* PWM FAN DRIVER -M: Kamil Debski <k.deb...@samsung.com> +M: Kamil Debski <ka...@wypas.org> +M: Lukasz Majewski <l.majew...@samsung.com> L: linux-hw...@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -9985,7 +9988,8 @@ T:git https://github.com/lmajewski/linux-samsung-thermal.git F: drivers/thermal/samsung/ SAMSUNG USB2 PHY DRIVER -M: Kamil Debski <k.deb...@samsung.com> +M: Kamil Debski <ka...@wypas.org> +M: Sylwester Nawrocki <s.nawro...@samsung.com> L: linux-kernel@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/phy/samsung-phy.txt -- 1.9.1
[PATCH] MAINTAINERS: update email and list of Samsung HW driver maintainers
Change my email address in the MAINTAINERS file. Add new maintainers of selected Samsung HW drivers. Signed-off-by: Kamil Debski Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: Guenter Roeck Cc: Kishon Vijay Abraham I Cc: Mauro Carvalho Chehab Cc: linux-hw...@vger.kernel.org Cc: Andrzej Hajda Cc: Lukasz Majewski Cc: Sylwester Nawrocki Cc: Kamil Debski --- MAINTAINERS | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8c20323..76e5953 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1623,7 +1623,8 @@ F:arch/arm/mach-s5pv210/ ARM/SAMSUNG S5P SERIES 2D GRAPHICS ACCELERATION (G2D) SUPPORT M: Kyungmin Park -M: Kamil Debski +M: Kamil Debski +M: Andrzej Hajda L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -1631,8 +1632,9 @@ F:drivers/media/platform/s5p-g2d/ ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC) SUPPORT M: Kyungmin Park -M: Kamil Debski +M: Kamil Debski M: Jeongtae Park +M: Andrzej Hajda L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -9241,7 +9243,8 @@ S:Maintained F: drivers/media/usb/pwc/* PWM FAN DRIVER -M: Kamil Debski +M: Kamil Debski +M: Lukasz Majewski L: linux-hw...@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -9985,7 +9988,8 @@ T:git https://github.com/lmajewski/linux-samsung-thermal.git F: drivers/thermal/samsung/ SAMSUNG USB2 PHY DRIVER -M: Kamil Debski +M: Kamil Debski +M: Sylwester Nawrocki L: linux-kernel@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/phy/samsung-phy.txt -- 1.9.1
RE: [PATCH] media: s5p-mfc fix memory leak in s5p_mfc_remove()
HI Shuah, Which branch do you base your patches on? I have trouble applying this path (https://patchwork.linuxtv.org/patch/34577/) and "s5p-mfc fix null pointer deference in clk_core_enable()" (https://patchwork.linuxtv.org/patch/34751/) onto current linuxtv/master. The top commit of linuxtv/master is : "commit 0db5c79989de2c68d5abb7ba891bfdb3cd3b7e05 Author: Mauro Carvalho Chehab <mche...@s-opensource.com> Date: Thu Jun 16 08:04:40 2016 -0300 [media] media-devnode.h: Fix documentation" Could you please rebase the two patches mentioned above to the linuxtv/master? Best wishes, -- Kamil Debski Samsung R Institute Poland > -Original Message- > From: Shuah Khan [mailto:shua...@osg.samsung.com] > Sent: Monday, June 13, 2016 9:45 PM > To: kyungmin.p...@samsung.com; k.deb...@samsung.com; > jtp.p...@samsung.com; mche...@osg.samsung.com > Cc: Shuah Khan; linux-arm-ker...@lists.infradead.org; linux- > me...@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH] media: s5p-mfc fix memory leak in s5p_mfc_remove() > > s5p_mfc_remove() fails to release encoder and decoder video devices. > > Signed-off-by: Shuah Khan <shua...@osg.samsung.com> > Reviewed-by: Javier Martinez Canillas <jav...@osg.samsung.com> > --- > > Changes since v1: > - Addressed comments from Javier Martinez Canillas and added > his reviewed by: > > drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index 274b4f1..f537b74 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -1318,6 +1318,8 @@ static int s5p_mfc_remove(struct platform_device > *pdev) > > video_unregister_device(dev->vfd_enc); > video_unregister_device(dev->vfd_dec); > + video_device_release(dev->vfd_enc); > + video_device_release(dev->vfd_dec); > v4l2_device_unregister(>v4l2_dev); > s5p_mfc_release_firmware(dev); > vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); > -- > 2.7.4
RE: [PATCH] media: s5p-mfc fix memory leak in s5p_mfc_remove()
HI Shuah, Which branch do you base your patches on? I have trouble applying this path (https://patchwork.linuxtv.org/patch/34577/) and "s5p-mfc fix null pointer deference in clk_core_enable()" (https://patchwork.linuxtv.org/patch/34751/) onto current linuxtv/master. The top commit of linuxtv/master is : "commit 0db5c79989de2c68d5abb7ba891bfdb3cd3b7e05 Author: Mauro Carvalho Chehab Date: Thu Jun 16 08:04:40 2016 -0300 [media] media-devnode.h: Fix documentation" Could you please rebase the two patches mentioned above to the linuxtv/master? Best wishes, -- Kamil Debski Samsung R Institute Poland > -Original Message- > From: Shuah Khan [mailto:shua...@osg.samsung.com] > Sent: Monday, June 13, 2016 9:45 PM > To: kyungmin.p...@samsung.com; k.deb...@samsung.com; > jtp.p...@samsung.com; mche...@osg.samsung.com > Cc: Shuah Khan; linux-arm-ker...@lists.infradead.org; linux- > me...@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH] media: s5p-mfc fix memory leak in s5p_mfc_remove() > > s5p_mfc_remove() fails to release encoder and decoder video devices. > > Signed-off-by: Shuah Khan > Reviewed-by: Javier Martinez Canillas > --- > > Changes since v1: > - Addressed comments from Javier Martinez Canillas and added > his reviewed by: > > drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index 274b4f1..f537b74 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -1318,6 +1318,8 @@ static int s5p_mfc_remove(struct platform_device > *pdev) > > video_unregister_device(dev->vfd_enc); > video_unregister_device(dev->vfd_dec); > + video_device_release(dev->vfd_enc); > + video_device_release(dev->vfd_dec); > v4l2_device_unregister(>v4l2_dev); > s5p_mfc_release_firmware(dev); > vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); > -- > 2.7.4
RE: [PATCH v5 08/46] hwmon: pwm-fan: use pwm_get_args() where appropriate
Hi Boris, From: Boris Brezillon [mailto:boris.brezil...@free-electrons.com] Sent: Wednesday, March 30, 2016 10:04 PM Subject: [PATCH v5 08/46] hwmon: pwm-fan: use pwm_get_args() where appropriate > > The PWM framework has clarified the concept of reference PWM config (the > platform dependent config retrieved from the DT or the PWM lookup table) > and real PWM state. > > Use pwm_get_args() when the PWM user wants to retrieve this reference > config and not the current state. > > This is part of the rework allowing the PWM framework to support hardware > readout and expose real PWM state even when the PWM has just been > requested (before the user calls pwm_config/enable/disable()). > > Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com> Acked-by: Kamil Debski <k.deb...@samsung.com> Best wishes, -- Kamil Debski Samsung R Institute Poland
RE: [PATCH v5 08/46] hwmon: pwm-fan: use pwm_get_args() where appropriate
Hi Boris, From: Boris Brezillon [mailto:boris.brezil...@free-electrons.com] Sent: Wednesday, March 30, 2016 10:04 PM Subject: [PATCH v5 08/46] hwmon: pwm-fan: use pwm_get_args() where appropriate > > The PWM framework has clarified the concept of reference PWM config (the > platform dependent config retrieved from the DT or the PWM lookup table) > and real PWM state. > > Use pwm_get_args() when the PWM user wants to retrieve this reference > config and not the current state. > > This is part of the rework allowing the PWM framework to support hardware > readout and expose real PWM state even when the PWM has just been > requested (before the user calls pwm_config/enable/disable()). > > Signed-off-by: Boris Brezillon Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland
RE: [PATCH v5 35/46] hwmon: pwm-fan: switch to the atomic API
Hi Boris, From: Boris Brezillon [mailto:boris.brezil...@free-electrons.com] Sent: Wednesday, March 30, 2016 10:04 PM Subject: [PATCH v5 35/46] hwmon: pwm-fan: switch to the atomic API > > pwm_config/enable/disable() have been deprecated and should be replaced > by pwm_apply_state(). > > Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com> Acked-by: Kamil Debski <k.deb...@samsung.com> Best wishes, -- Kamil Debski Samsung R Institute Poland
RE: [PATCH v5 35/46] hwmon: pwm-fan: switch to the atomic API
Hi Boris, From: Boris Brezillon [mailto:boris.brezil...@free-electrons.com] Sent: Wednesday, March 30, 2016 10:04 PM Subject: [PATCH v5 35/46] hwmon: pwm-fan: switch to the atomic API > > pwm_config/enable/disable() have been deprecated and should be replaced > by pwm_apply_state(). > > Signed-off-by: Boris Brezillon Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland
RE: [PATCH 1/1] mtd: nand_bbt: separate struct nand_chip from nand_bbt.c
Hi Peter, Thank you for work on this. I have applied this patch to the latest kernel and it had some minor merge conflicts that needed to be resolved. But apart from this it compiled and worked in my setup. My testing procedure was following: 1) I applied your patch to the NAND core 2) I applied old SPI NAND patches by Ezequiel Garcia. His patches use the NAND core as a bridge between the SPI NAND core and MTD core. Hence it was possible to test changes in the NAND core. 3) The kernel compiled and booted. I then run nandtest and it finished successfully. I know that you have prepared a patch that adds the SPI NAND core and that uses common BBT. I think that it is a good idea to send it along with a v2 of this patch rebased to the 4.1 or the next branch of Brain Norris. I would really like to test it :) I have read the patch code and I have this one minor comment. Please find it below. Best wishes, Kamil Debski From: linux-mtd [mailto:linux-mtd-boun...@lists.infradead.org] On Behalf Of Peter Pan ?? (peterpandong) Sent: 15 May 2015 08:32 > Currently nand_bbt.c is tied with struct nand_chip, and it makes other > NAND family chips hard to use nand_bbt.c. Maybe it's the reason why > onenand has own bbt(onenand_bbt.c). > > Parameterize a few relevant device detail information into a new > nand_bbt struct, and set some hooks for chip specified part. Allocate > and initialize struct nand_bbt in nand_base.c. > > Most of the patch is borrowed from Brian Norris > . > http://git.infradead.org/users/norris/linux- > mtd.git/shortlog/refs/heads/nand-bbt > > Signed-off-by: Peter Pan > Signed-off-by: Brian Norris Tested-by: Kamil Debski > --- > drivers/mtd/nand/docg4.c | 8 +- > drivers/mtd/nand/nand_base.c | 145 +++- > drivers/mtd/nand/nand_bbt.c | 518 +- > - > include/linux/mtd/bbm.h | 96 +--- > include/linux/mtd/nand.h | 11 +- > include/linux/mtd/nand_bbt.h | 160 + > 6 files changed, 516 insertions(+), 422 deletions(-) > create mode 100644 include/linux/mtd/nand_bbt.h > [ snip] > diff --git a/include/linux/mtd/nand_bbt.h b/include/linux/mtd/nand_bbt.h > new file mode 100644 > index 000..03ee0eb > --- /dev/null > +++ b/include/linux/mtd/nand_bbt.h > @@ -0,0 +1,160 @@ > +/* > + * NAND family Bad Block Table support > + * > + * Copyright © 2015 Broadcom Corporation > + * Brian Norris > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > +#ifndef __LINUX_MTD_NAND_BBT_H > +#define __LINUX_MTD_NAND_BBT_H > + > +struct mtd_info; > + > +/* The maximum number of NAND chips in an array */ > +#define NAND_MAX_CHIPS 8 > + > +/** > + * struct nand_bbt_descr - bad block table descriptor > + * @options: options for this descriptor > + * @pages: the page(s) where we find the bbt, used with option > BBT_ABSPAGE > + * when bbt is searched, then we store the found bbts pages > here. > + * Its an array and supports up to 8 chips now > + * @offs:offset of the pattern in the oob area of the page > + * @veroffs: offset of the bbt version counter in the oob are of the page > + * @version: version read from the bbt page during scan > + * @len: length of the pattern, if 0 no pattern check is performed > + * @maxblocks: maximum number of blocks to search for a bbt. This > number of > + * blocks is reserved at the end of the device where the tables > are > + * written. > + * @reserved_block_code: if non-0, this pattern denotes a reserved (rather > than > + * bad) block in the stored bbt > + * @pattern: pattern to identify bad block table or factory marked good / > + * bad blocks, can be NULL, if len = 0 > + * > + * Descriptor for the bad block table marker and the descriptor for the > + * pattern which identifies good and bad blocks. The assumption is made > + * that the pattern and the version count are always located in the oob area > + * of the first block. > + */ > +struct nand_bbt_descr { > + int options; > + int pages[NAND_MAX_CHIPS]; > + int offs; > + int veroffs; > + uint8_t version[NAND_MAX_CHIPS]; > + int len; > +
RE: [PATCH 1/1] mtd: nand_bbt: separate struct nand_chip from nand_bbt.c
Hi Peter, Thank you for work on this. I have applied this patch to the latest kernel and it had some minor merge conflicts that needed to be resolved. But apart from this it compiled and worked in my setup. My testing procedure was following: 1) I applied your patch to the NAND core 2) I applied old SPI NAND patches by Ezequiel Garcia. His patches use the NAND core as a bridge between the SPI NAND core and MTD core. Hence it was possible to test changes in the NAND core. 3) The kernel compiled and booted. I then run nandtest and it finished successfully. I know that you have prepared a patch that adds the SPI NAND core and that uses common BBT. I think that it is a good idea to send it along with a v2 of this patch rebased to the 4.1 or the next branch of Brain Norris. I would really like to test it :) I have read the patch code and I have this one minor comment. Please find it below. Best wishes, Kamil Debski From: linux-mtd [mailto:linux-mtd-boun...@lists.infradead.org] On Behalf Of Peter Pan ?? (peterpandong) Sent: 15 May 2015 08:32 Currently nand_bbt.c is tied with struct nand_chip, and it makes other NAND family chips hard to use nand_bbt.c. Maybe it's the reason why onenand has own bbt(onenand_bbt.c). Parameterize a few relevant device detail information into a new nand_bbt struct, and set some hooks for chip specified part. Allocate and initialize struct nand_bbt in nand_base.c. Most of the patch is borrowed from Brian Norris computersforpe...@gmail.com. http://git.infradead.org/users/norris/linux- mtd.git/shortlog/refs/heads/nand-bbt Signed-off-by: Peter Pan peterpand...@micron.com Signed-off-by: Brian Norris computersforpe...@gmail.com Tested-by: Kamil Debski kamil.deb...@imgtec.com --- drivers/mtd/nand/docg4.c | 8 +- drivers/mtd/nand/nand_base.c | 145 +++- drivers/mtd/nand/nand_bbt.c | 518 +- - include/linux/mtd/bbm.h | 96 +--- include/linux/mtd/nand.h | 11 +- include/linux/mtd/nand_bbt.h | 160 + 6 files changed, 516 insertions(+), 422 deletions(-) create mode 100644 include/linux/mtd/nand_bbt.h [ snip] diff --git a/include/linux/mtd/nand_bbt.h b/include/linux/mtd/nand_bbt.h new file mode 100644 index 000..03ee0eb --- /dev/null +++ b/include/linux/mtd/nand_bbt.h @@ -0,0 +1,160 @@ +/* + * NAND family Bad Block Table support + * + * Copyright © 2015 Broadcom Corporation + * Brian Norris computersforpe...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef __LINUX_MTD_NAND_BBT_H +#define __LINUX_MTD_NAND_BBT_H + +struct mtd_info; + +/* The maximum number of NAND chips in an array */ +#define NAND_MAX_CHIPS 8 + +/** + * struct nand_bbt_descr - bad block table descriptor + * @options: options for this descriptor + * @pages: the page(s) where we find the bbt, used with option BBT_ABSPAGE + * when bbt is searched, then we store the found bbts pages here. + * Its an array and supports up to 8 chips now + * @offs:offset of the pattern in the oob area of the page + * @veroffs: offset of the bbt version counter in the oob are of the page + * @version: version read from the bbt page during scan + * @len: length of the pattern, if 0 no pattern check is performed + * @maxblocks: maximum number of blocks to search for a bbt. This number of + * blocks is reserved at the end of the device where the tables are + * written. + * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than + * bad) block in the stored bbt + * @pattern: pattern to identify bad block table or factory marked good / + * bad blocks, can be NULL, if len = 0 + * + * Descriptor for the bad block table marker and the descriptor for the + * pattern which identifies good and bad blocks. The assumption is made + * that the pattern and the version count are always located in the oob area + * of the first block. + */ +struct nand_bbt_descr { + int options; + int pages[NAND_MAX_CHIPS]; + int offs; + int veroffs; + uint8_t version[NAND_MAX_CHIPS]; + int len; + int maxblocks; + int reserved_block_code; + uint8_t *pattern; +}; + +/* Options for the bad block table descriptors */ + +/* The number of bits used per block in the bbt on the device */ +#define NAND_BBT_NRBITS_MSK 0x000F +#define NAND_BBT_1BIT
RE: [PATCH] phy: samsung-usb2: Remove NULL terminating entry from phys array
From: Axel Lin [mailto:axel@ingics.com] Sent: Tuesday, March 03, 2015 2:09 AM > > Current code uses num_phys settings to tell the number of entries in > phys. > Thus remove the NULL terminating entry from phys array which is not > necessary. The patch looks good. > Signed-off-by: Axel Lin Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland > --- > drivers/phy/phy-exynos4210-usb2.c | 1 - drivers/phy/phy-exynos4x12- > usb2.c | 1 - drivers/phy/phy-exynos5250-usb2.c | 1 - > 3 files changed, 3 deletions(-) > > diff --git a/drivers/phy/phy-exynos4210-usb2.c b/drivers/phy/phy- > exynos4210-usb2.c > index 236a52a..f30bbb0 100644 > --- a/drivers/phy/phy-exynos4210-usb2.c > +++ b/drivers/phy/phy-exynos4210-usb2.c > @@ -250,7 +250,6 @@ static const struct samsung_usb2_common_phy > exynos4210_phys[] = { > .power_on = exynos4210_power_on, > .power_off = exynos4210_power_off, > }, > - {}, > }; > > const struct samsung_usb2_phy_config exynos4210_usb2_phy_config = { > diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy- > exynos4x12-usb2.c > index 0b9de88..765da90 100644 > --- a/drivers/phy/phy-exynos4x12-usb2.c > +++ b/drivers/phy/phy-exynos4x12-usb2.c > @@ -361,7 +361,6 @@ static const struct samsung_usb2_common_phy > exynos4x12_phys[] = { > .power_on = exynos4x12_power_on, > .power_off = exynos4x12_power_off, > }, > - {}, > }; > > const struct samsung_usb2_phy_config exynos3250_usb2_phy_config = { > diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy- > exynos5250-usb2.c > index 1c139aa..2ed1735 100644 > --- a/drivers/phy/phy-exynos5250-usb2.c > +++ b/drivers/phy/phy-exynos5250-usb2.c > @@ -391,7 +391,6 @@ static const struct samsung_usb2_common_phy > exynos5250_phys[] = { > .power_on = exynos5250_power_on, > .power_off = exynos5250_power_off, > }, > - {}, > }; > > const struct samsung_usb2_phy_config exynos5250_usb2_phy_config = { > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: samsung-usb2: Remove NULL terminating entry from phys array
From: Axel Lin [mailto:axel@ingics.com] Sent: Tuesday, March 03, 2015 2:09 AM Current code uses num_phys settings to tell the number of entries in phys. Thus remove the NULL terminating entry from phys array which is not necessary. The patch looks good. Signed-off-by: Axel Lin axel@ingics.com Acked-by: Kamil Debski k.deb...@samsung.com Best wishes, -- Kamil Debski Samsung RD Institute Poland --- drivers/phy/phy-exynos4210-usb2.c | 1 - drivers/phy/phy-exynos4x12- usb2.c | 1 - drivers/phy/phy-exynos5250-usb2.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/phy/phy-exynos4210-usb2.c b/drivers/phy/phy- exynos4210-usb2.c index 236a52a..f30bbb0 100644 --- a/drivers/phy/phy-exynos4210-usb2.c +++ b/drivers/phy/phy-exynos4210-usb2.c @@ -250,7 +250,6 @@ static const struct samsung_usb2_common_phy exynos4210_phys[] = { .power_on = exynos4210_power_on, .power_off = exynos4210_power_off, }, - {}, }; const struct samsung_usb2_phy_config exynos4210_usb2_phy_config = { diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy- exynos4x12-usb2.c index 0b9de88..765da90 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -361,7 +361,6 @@ static const struct samsung_usb2_common_phy exynos4x12_phys[] = { .power_on = exynos4x12_power_on, .power_off = exynos4x12_power_off, }, - {}, }; const struct samsung_usb2_phy_config exynos3250_usb2_phy_config = { diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy- exynos5250-usb2.c index 1c139aa..2ed1735 100644 --- a/drivers/phy/phy-exynos5250-usb2.c +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -391,7 +391,6 @@ static const struct samsung_usb2_common_phy exynos5250_phys[] = { .power_on = exynos5250_power_on, .power_off = exynos5250_power_off, }, - {}, }; const struct samsung_usb2_phy_config exynos5250_usb2_phy_config = { -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: phy-samsung-usb2: Don't use same name for driver name and global structure
Hi, > From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] > Sent: Thursday, December 11, 2014 7:30 AM > To: Kishon Vijay Abraham I; Kamil Debski > Cc: linux-kernel@vger.kernel.org; Linux USB Mailing List; Vivek Gautam > Subject: Re: [PATCH] phy: phy-samsung-usb2: Don't use same name for > driver name and global structure > > On Wed, Nov 12, 2014 at 3:54 PM, Vivek Gautam > wrote: > > Using the same driver name for platform driver and a globally defined, > > structure used throughout the file, looks a bit unpleasing. > > So changing the driver name from "samsung_usb2_phy_driver" to > > "samsung_usb2_phy" > > > > Signed-off-by: Vivek Gautam > > Cc: Kamil Debski > > Cc: Kishon Vijay Abraham I > > --- > > Although just a trivial change, does it look valid ? I can agree that the naming of this variable is a bit unfortunate. Changing name of samsung_usb2_phy_driver to samsung_usb2_phy is, as you said, a minor change and does not change how the driver works. Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland > > > drivers/phy/phy-samsung-usb2.c |4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- > samsung-usb2.c > > index 908949d..2934fb7 100644 > > --- a/drivers/phy/phy-samsung-usb2.c > > +++ b/drivers/phy/phy-samsung-usb2.c > > @@ -226,7 +226,7 @@ static int samsung_usb2_phy_probe(struct > platform_device *pdev) > > return 0; > > } > > > > -static struct platform_driver samsung_usb2_phy_driver = { > > +static struct platform_driver samsung_usb2_phy = { > > .probe = samsung_usb2_phy_probe, > > .driver = { > > .of_match_table = samsung_usb2_phy_of_match, > > @@ -234,7 +234,7 @@ static struct platform_driver > samsung_usb2_phy_driver = { > > } > > }; > > > > -module_platform_driver(samsung_usb2_phy_driver); > > +module_platform_driver(samsung_usb2_phy); > > MODULE_DESCRIPTION("Samsung S5P/EXYNOS SoC USB PHY driver"); > > MODULE_AUTHOR("Kamil Debski "); > > MODULE_LICENSE("GPL v2"); > > -- > > 1.7.10.4 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux- > kernel" in > > the body of a message to majord...@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > Please read the FAQ at http://www.tux.org/lkml/ > > > > -- > Best Regards > Vivek Gautam > Samsung R Institute, Bangalore > India -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: phy-samsung-usb2: Don't use same name for driver name and global structure
Hi, From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] Sent: Thursday, December 11, 2014 7:30 AM To: Kishon Vijay Abraham I; Kamil Debski Cc: linux-kernel@vger.kernel.org; Linux USB Mailing List; Vivek Gautam Subject: Re: [PATCH] phy: phy-samsung-usb2: Don't use same name for driver name and global structure On Wed, Nov 12, 2014 at 3:54 PM, Vivek Gautam gautam.vi...@samsung.com wrote: Using the same driver name for platform driver and a globally defined, structure used throughout the file, looks a bit unpleasing. So changing the driver name from samsung_usb2_phy_driver to samsung_usb2_phy Signed-off-by: Vivek Gautam gautam.vi...@samsung.com Cc: Kamil Debski k.deb...@samsung.com Cc: Kishon Vijay Abraham I kis...@ti.com --- Although just a trivial change, does it look valid ? I can agree that the naming of this variable is a bit unfortunate. Changing name of samsung_usb2_phy_driver to samsung_usb2_phy is, as you said, a minor change and does not change how the driver works. Acked-by: Kamil Debski k.deb...@samsung.com Best wishes, -- Kamil Debski Samsung RD Institute Poland drivers/phy/phy-samsung-usb2.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- samsung-usb2.c index 908949d..2934fb7 100644 --- a/drivers/phy/phy-samsung-usb2.c +++ b/drivers/phy/phy-samsung-usb2.c @@ -226,7 +226,7 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev) return 0; } -static struct platform_driver samsung_usb2_phy_driver = { +static struct platform_driver samsung_usb2_phy = { .probe = samsung_usb2_phy_probe, .driver = { .of_match_table = samsung_usb2_phy_of_match, @@ -234,7 +234,7 @@ static struct platform_driver samsung_usb2_phy_driver = { } }; -module_platform_driver(samsung_usb2_phy_driver); +module_platform_driver(samsung_usb2_phy); MODULE_DESCRIPTION(Samsung S5P/EXYNOS SoC USB PHY driver); MODULE_AUTHOR(Kamil Debski k.deb...@samsung.com); MODULE_LICENSE(GPL v2); -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux- kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- Best Regards Vivek Gautam Samsung RD Institute, Bangalore India -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
Hi, > From: Rafael J. Wysocki [mailto:r...@rjwysocki.net] > Sent: Wednesday, December 03, 2014 3:14 AM > To: linux-me...@vger.kernel.org > Cc: Kyungmin Park; Sylwester Nawrocki; Mauro Carvalho Chehab; Kukjin > Kim; linux-samsung-...@vger.kernel.org; Kamil Debski; Philipp Zabel; > Linux PM list; Linux Kernel Mailing List > Subject: [PATCH] media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM > > From: Rafael J. Wysocki > > After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is > selected) PM_RUNTIME is always set if PM is set, so #ifdef blocks > depending on CONFIG_PM_RUNTIME may now be changed to depend on > CONFIG_PM. > > The alternative of CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME may be > replaced with CONFIG_PM too. > > Make these changes everywhere under drivers/media/. > > Signed-off-by: Rafael J. Wysocki > --- > > Note: This depends on commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME > if > PM_SLEEP is selected) which is only in linux-next at the moment (via > the > linux-pm tree). > > Please let me know if it is OK to take this one into linux-pm. Looks good, for the s5p_mfc part, Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
Hi, From: Rafael J. Wysocki [mailto:r...@rjwysocki.net] Sent: Wednesday, December 03, 2014 3:14 AM To: linux-me...@vger.kernel.org Cc: Kyungmin Park; Sylwester Nawrocki; Mauro Carvalho Chehab; Kukjin Kim; linux-samsung-...@vger.kernel.org; Kamil Debski; Philipp Zabel; Linux PM list; Linux Kernel Mailing List Subject: [PATCH] media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM From: Rafael J. Wysocki rafael.j.wyso...@intel.com After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is selected) PM_RUNTIME is always set if PM is set, so #ifdef blocks depending on CONFIG_PM_RUNTIME may now be changed to depend on CONFIG_PM. The alternative of CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME may be replaced with CONFIG_PM too. Make these changes everywhere under drivers/media/. Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com --- Note: This depends on commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is selected) which is only in linux-next at the moment (via the linux-pm tree). Please let me know if it is OK to take this one into linux-pm. Looks good, for the s5p_mfc part, Acked-by: Kamil Debski k.deb...@samsung.com Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 09/12] media: s5p-mfc: use vb2_ops_wait_prepare/finish helper
Hi, Please provide a commit description. No matter how obvious the commit seems. Best wishes, -- Kamil Debski Samsung R Institute Poland > -Original Message- > From: Lad, Prabhakar [mailto:prabhakar.cse...@gmail.com] > Sent: Tuesday, November 18, 2014 12:24 PM > To: Hans Verkuil; Mauro Carvalho Chehab; LMML > Cc: LKML; Lad, Prabhakar; Kyungmin Park; Kamil Debski; Jeongtae Park > Subject: [PATCH 09/12] media: s5p-mfc: use vb2_ops_wait_prepare/finish > helper > > Signed-off-by: Lad, Prabhakar > Cc: Kyungmin Park > Cc: Kamil Debski > Cc: Jeongtae Park > --- > drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + > drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 20 ++-- > drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 20 ++-- > 3 files changed, 5 insertions(+), 36 deletions(-) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index 03204fd..52f65e9 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -810,6 +810,7 @@ static int s5p_mfc_open(struct file *file) > q = >vq_dst; > q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; > q->drv_priv = >fh; > + q->lock = >mfc_mutex; > if (vdev == dev->vfd_dec) { > q->io_modes = VB2_MMAP; > q->ops = get_dec_queue_ops(); > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > index 74bcec8..78b3e0e 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > @@ -946,22 +946,6 @@ static int s5p_mfc_queue_setup(struct vb2_queue > *vq, > return 0; > } > > -static void s5p_mfc_unlock(struct vb2_queue *q) -{ > - struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv); > - struct s5p_mfc_dev *dev = ctx->dev; > - > - mutex_unlock(>mfc_mutex); > -} > - > -static void s5p_mfc_lock(struct vb2_queue *q) -{ > - struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv); > - struct s5p_mfc_dev *dev = ctx->dev; > - > - mutex_lock(>mfc_mutex); > -} > - > static int s5p_mfc_buf_init(struct vb2_buffer *vb) { > struct vb2_queue *vq = vb->vb2_queue; > @@ -1109,8 +1093,8 @@ static void s5p_mfc_buf_queue(struct vb2_buffer > *vb) > > static struct vb2_ops s5p_mfc_dec_qops = { > .queue_setup= s5p_mfc_queue_setup, > - .wait_prepare = s5p_mfc_unlock, > - .wait_finish= s5p_mfc_lock, > + .wait_prepare = vb2_ops_wait_prepare, > + .wait_finish= vb2_ops_wait_finish, > .buf_init = s5p_mfc_buf_init, > .start_streaming= s5p_mfc_start_streaming, > .stop_streaming = s5p_mfc_stop_streaming, > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c > index e7240cb..ffa9c1d 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c > @@ -1869,22 +1869,6 @@ static int s5p_mfc_queue_setup(struct vb2_queue > *vq, > return 0; > } > > -static void s5p_mfc_unlock(struct vb2_queue *q) -{ > - struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv); > - struct s5p_mfc_dev *dev = ctx->dev; > - > - mutex_unlock(>mfc_mutex); > -} > - > -static void s5p_mfc_lock(struct vb2_queue *q) -{ > - struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv); > - struct s5p_mfc_dev *dev = ctx->dev; > - > - mutex_lock(>mfc_mutex); > -} > - > static int s5p_mfc_buf_init(struct vb2_buffer *vb) { > struct vb2_queue *vq = vb->vb2_queue; > @@ -2054,8 +2038,8 @@ static void s5p_mfc_buf_queue(struct vb2_buffer > *vb) > > static struct vb2_ops s5p_mfc_enc_qops = { > .queue_setup= s5p_mfc_queue_setup, > - .wait_prepare = s5p_mfc_unlock, > - .wait_finish= s5p_mfc_lock, > + .wait_prepare = vb2_ops_wait_prepare, > + .wait_finish= vb2_ops_wait_finish, > .buf_init = s5p_mfc_buf_init, > .buf_prepare= s5p_mfc_buf_prepare, > .start_streaming= s5p_mfc_start_streaming, > -- > 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 09/12] media: s5p-mfc: use vb2_ops_wait_prepare/finish helper
Hi, Please provide a commit description. No matter how obvious the commit seems. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Lad, Prabhakar [mailto:prabhakar.cse...@gmail.com] Sent: Tuesday, November 18, 2014 12:24 PM To: Hans Verkuil; Mauro Carvalho Chehab; LMML Cc: LKML; Lad, Prabhakar; Kyungmin Park; Kamil Debski; Jeongtae Park Subject: [PATCH 09/12] media: s5p-mfc: use vb2_ops_wait_prepare/finish helper Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com Cc: Kyungmin Park kyungmin.p...@samsung.com Cc: Kamil Debski k.deb...@samsung.com Cc: Jeongtae Park jtp.p...@samsung.com --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 20 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 20 ++-- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 03204fd..52f65e9 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -810,6 +810,7 @@ static int s5p_mfc_open(struct file *file) q = ctx-vq_dst; q-type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q-drv_priv = ctx-fh; + q-lock = dev-mfc_mutex; if (vdev == dev-vfd_dec) { q-io_modes = VB2_MMAP; q-ops = get_dec_queue_ops(); diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index 74bcec8..78b3e0e 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c @@ -946,22 +946,6 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, return 0; } -static void s5p_mfc_unlock(struct vb2_queue *q) -{ - struct s5p_mfc_ctx *ctx = fh_to_ctx(q-drv_priv); - struct s5p_mfc_dev *dev = ctx-dev; - - mutex_unlock(dev-mfc_mutex); -} - -static void s5p_mfc_lock(struct vb2_queue *q) -{ - struct s5p_mfc_ctx *ctx = fh_to_ctx(q-drv_priv); - struct s5p_mfc_dev *dev = ctx-dev; - - mutex_lock(dev-mfc_mutex); -} - static int s5p_mfc_buf_init(struct vb2_buffer *vb) { struct vb2_queue *vq = vb-vb2_queue; @@ -1109,8 +1093,8 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb) static struct vb2_ops s5p_mfc_dec_qops = { .queue_setup= s5p_mfc_queue_setup, - .wait_prepare = s5p_mfc_unlock, - .wait_finish= s5p_mfc_lock, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish= vb2_ops_wait_finish, .buf_init = s5p_mfc_buf_init, .start_streaming= s5p_mfc_start_streaming, .stop_streaming = s5p_mfc_stop_streaming, diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index e7240cb..ffa9c1d 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -1869,22 +1869,6 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, return 0; } -static void s5p_mfc_unlock(struct vb2_queue *q) -{ - struct s5p_mfc_ctx *ctx = fh_to_ctx(q-drv_priv); - struct s5p_mfc_dev *dev = ctx-dev; - - mutex_unlock(dev-mfc_mutex); -} - -static void s5p_mfc_lock(struct vb2_queue *q) -{ - struct s5p_mfc_ctx *ctx = fh_to_ctx(q-drv_priv); - struct s5p_mfc_dev *dev = ctx-dev; - - mutex_lock(dev-mfc_mutex); -} - static int s5p_mfc_buf_init(struct vb2_buffer *vb) { struct vb2_queue *vq = vb-vb2_queue; @@ -2054,8 +2038,8 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb) static struct vb2_ops s5p_mfc_enc_qops = { .queue_setup= s5p_mfc_queue_setup, - .wait_prepare = s5p_mfc_unlock, - .wait_finish= s5p_mfc_lock, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish= vb2_ops_wait_finish, .buf_init = s5p_mfc_buf_init, .buf_prepare= s5p_mfc_buf_prepare, .start_streaming= s5p_mfc_start_streaming, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] ARM: dts: Add pwm-fan node to the Odroid-U3 board
Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the cooling fan. In addition, add the "pwm" label to the pwm@139D node in the exynos4412.dtsi. Signed-off-by: Kamil Debski --- Changes since v1: - added pwm label to the pwm@139D node in exynos4.dtsi - use the pwm label in the exynos4412-odroidu3.dts - change order or properties in the pwn-fan node, to be sorted in alphabetical order --- arch/arm/boot/dts/exynos4.dtsi|2 +- arch/arm/boot/dts/exynos4412-odroidu3.dts | 14 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index e0278ec..2843b1a 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -582,7 +582,7 @@ status = "disabled"; }; - pwm@139D { + pwm: pwm@139D { compatible = "samsung,exynos4210-pwm"; reg = <0x139D 0x1000>; interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>; diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts index c8a64be..973349b 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts @@ -31,8 +31,22 @@ linux,default-trigger = "heartbeat"; }; }; + + pwm-fan { + compatible = "pwm-fan"; + pwms = < 0 1 0>; + status = "okay"; + }; }; + { + pinctrl-0 = <_out>; + pinctrl-names = "default"; + samsung,pwm-outputs = <0>; + status = "okay"; +}; + + { clock-names = "refclk"; clocks = <_system_controller 0>; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] ARM: dts: Add pwm-fan node to the Odroid-U3 board
Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the cooling fan. In addition, add the pwm label to the pwm@139D node in the exynos4412.dtsi. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v1: - added pwm label to the pwm@139D node in exynos4.dtsi - use the pwm label in the exynos4412-odroidu3.dts - change order or properties in the pwn-fan node, to be sorted in alphabetical order --- arch/arm/boot/dts/exynos4.dtsi|2 +- arch/arm/boot/dts/exynos4412-odroidu3.dts | 14 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index e0278ec..2843b1a 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -582,7 +582,7 @@ status = disabled; }; - pwm@139D { + pwm: pwm@139D { compatible = samsung,exynos4210-pwm; reg = 0x139D 0x1000; interrupts = 0 37 0, 0 38 0, 0 39 0, 0 40 0, 0 41 0; diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts index c8a64be..973349b 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts @@ -31,8 +31,22 @@ linux,default-trigger = heartbeat; }; }; + + pwm-fan { + compatible = pwm-fan; + pwms = pwm 0 1 0; + status = okay; + }; }; +pwm { + pinctrl-0 = pwm0_out; + pinctrl-names = default; + samsung,pwm-outputs = 0; + status = okay; +}; + + usb3503 { clock-names = refclk; clocks = pmu_system_controller 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior
The state of a PWM output is not clearly defined after resume. Some PWM drivers do not restore the duty cycle upon resume, thus it is necessary to manually restore the correct value. Signed-off-by: Kamil Debski --- drivers/hwmon/pwm-fan.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 823c877..1991d903 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev) static int pwm_fan_resume(struct device *dev) { struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + unsigned long duty; + int ret; - if (ctx->pwm_value) - return pwm_enable(ctx->pwm); - return 0; + if (ctx->pwm_value == 0) + return 0; + + duty = DIV_ROUND_UP(ctx->pwm_value * (ctx->pwm->period - 1), MAX_PWM); + ret = pwm_config(ctx->pwm, duty, ctx->pwm->period); + if (ret) + return ret; + return pwm_enable(ctx->pwm); } #endif -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] ARM: dts: Add pwm-fan node to the Odroid-U3 board
Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the cooling fan. Signed-off-by: Kamil Debski --- arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts index c8a64be..764bda4 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts @@ -31,6 +31,19 @@ linux,default-trigger = "heartbeat"; }; }; + + pwm: pwm@139D { + pinctrl-0 = <_out>; + pinctrl-names = "default"; + samsung,pwm-outputs = <0>; + status = "okay"; + }; + + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; }; { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior
The state of a PWM output is not clearly defined after resume. Some PWM drivers do not restore the duty cycle upon resume, thus it is necessary to manually restore the correct value. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/hwmon/pwm-fan.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 823c877..1991d903 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev) static int pwm_fan_resume(struct device *dev) { struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + unsigned long duty; + int ret; - if (ctx-pwm_value) - return pwm_enable(ctx-pwm); - return 0; + if (ctx-pwm_value == 0) + return 0; + + duty = DIV_ROUND_UP(ctx-pwm_value * (ctx-pwm-period - 1), MAX_PWM); + ret = pwm_config(ctx-pwm, duty, ctx-pwm-period); + if (ret) + return ret; + return pwm_enable(ctx-pwm); } #endif -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] ARM: dts: Add pwm-fan node to the Odroid-U3 board
Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the cooling fan. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts index c8a64be..764bda4 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts @@ -31,6 +31,19 @@ linux,default-trigger = heartbeat; }; }; + + pwm: pwm@139D { + pinctrl-0 = pwm0_out; + pinctrl-names = default; + samsung,pwm-outputs = 0; + status = okay; + }; + + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; }; usb3503 { -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] [media] s5p-mfc: Use decode status instead of display status on MFCv5
Hi Sjoerd, > From: linux-media-ow...@vger.kernel.org [mailto:linux-media- > ow...@vger.kernel.org] On Behalf Of Sjoerd Simons > Sent: Monday, September 22, 2014 2:52 PM > To: Kyungmin Park; Kamil Debski; Arun Kumar K > Cc: Mauro Carvalho Chehab; linux-arm-ker...@lists.infradead.org; linux- > me...@vger.kernel.org; linux-kernel@vger.kernel.org; linux-samsung- > s...@vger.kernel.org; Daniel Drake; Sjoerd Simons > Subject: [PATCH] [media] s5p-mfc: Use decode status instead of display > status on MFCv5 > > Commit 90c0ae50097 changed how the frame_type of a decoded frame > gets determined, by switching from the get_dec_frame_type to > get_disp_frame_type operation. Unfortunately it seems that on MFC v5 > the > result of get_disp_frame_type is always 0 (no display) when decoding > (tested with H264), resulting in no frame ever being output from the > decoder. Could you tell me which firmware version do you use (date)? Best wishes, -- Kamil Debski Samsung R Institute Poland > This patch reverts MFC v5 to the previous behaviour while keeping the > new behaviour for v6 and up. > > Signed-off-by: Sjoerd Simons > --- > drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index d35b041..27ca9d0 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -264,7 +264,12 @@ static void s5p_mfc_handle_frame_new(struct > s5p_mfc_ctx *ctx, unsigned int err) > unsigned int frame_type; > > dspl_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_y_adr, dev); > - frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_disp_frame_type, > ctx); > + if (IS_MFCV6_PLUS(dev)) > + frame_type = s5p_mfc_hw_call(dev->mfc_ops, > + get_disp_frame_type, ctx); > + else > + frame_type = s5p_mfc_hw_call(dev->mfc_ops, > + get_dec_frame_type, dev); > > /* If frame is same as previous then skip and do not dequeue */ > if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED) { > -- > 2.1.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] [media] s5p-mfc: Use decode status instead of display status on MFCv5
Hi Sjoerd, From: linux-media-ow...@vger.kernel.org [mailto:linux-media- ow...@vger.kernel.org] On Behalf Of Sjoerd Simons Sent: Monday, September 22, 2014 2:52 PM To: Kyungmin Park; Kamil Debski; Arun Kumar K Cc: Mauro Carvalho Chehab; linux-arm-ker...@lists.infradead.org; linux- me...@vger.kernel.org; linux-kernel@vger.kernel.org; linux-samsung- s...@vger.kernel.org; Daniel Drake; Sjoerd Simons Subject: [PATCH] [media] s5p-mfc: Use decode status instead of display status on MFCv5 Commit 90c0ae50097 changed how the frame_type of a decoded frame gets determined, by switching from the get_dec_frame_type to get_disp_frame_type operation. Unfortunately it seems that on MFC v5 the result of get_disp_frame_type is always 0 (no display) when decoding (tested with H264), resulting in no frame ever being output from the decoder. Could you tell me which firmware version do you use (date)? Best wishes, -- Kamil Debski Samsung RD Institute Poland This patch reverts MFC v5 to the previous behaviour while keeping the new behaviour for v6 and up. Signed-off-by: Sjoerd Simons sjoerd.sim...@collabora.co.uk --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index d35b041..27ca9d0 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -264,7 +264,12 @@ static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsigned int err) unsigned int frame_type; dspl_y_addr = s5p_mfc_hw_call(dev-mfc_ops, get_dspl_y_adr, dev); - frame_type = s5p_mfc_hw_call(dev-mfc_ops, get_disp_frame_type, ctx); + if (IS_MFCV6_PLUS(dev)) + frame_type = s5p_mfc_hw_call(dev-mfc_ops, + get_disp_frame_type, ctx); + else + frame_type = s5p_mfc_hw_call(dev-mfc_ops, + get_dec_frame_type, dev); /* If frame is same as previous then skip and do not dequeue */ if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED) { -- 2.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] MAINTAINERS: add entry for the Samsung USB2 PHY driver
Add MAINTAINERS entry for the Samsung USB2 PHY driver. Signed-off-by: Kamil Debski --- MAINTAINERS | 13 + 1 file changed, 13 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 05dc39d..548602f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7873,6 +7873,19 @@ S: Supported L: net...@vger.kernel.org F: drivers/net/ethernet/samsung/sxgbe/ +SAMSUNG USB2 PHY DRIVER +M: Kamil Debski +L: linux-kernel@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/phy/samsung-phy.txt +F: Documentation/phy/samsung-usb2.txt +F: drivers/phy/phy-exynos4210-usb2.c +F: drivers/phy/phy-exynos4x12-usb2.c +F: drivers/phy/phy-exynos5250-usb2.c +F: drivers/phy/phy-s5pv210-usb2.c +F: drivers/phy/phy-samsung-usb2.c +F: drivers/phy/phy-samsung-usb2.h + SERIAL DRIVERS M: Greg Kroah-Hartman L: linux-ser...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] MAINTAINERS: add entry for the Samsung USB2 PHY driver
Add MAINTAINERS entry for the Samsung USB2 PHY driver. Signed-off-by: Kamil Debski k.deb...@samsung.com --- MAINTAINERS | 13 + 1 file changed, 13 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 05dc39d..548602f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7873,6 +7873,19 @@ S: Supported L: net...@vger.kernel.org F: drivers/net/ethernet/samsung/sxgbe/ +SAMSUNG USB2 PHY DRIVER +M: Kamil Debski k.deb...@samsung.com +L: linux-kernel@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/phy/samsung-phy.txt +F: Documentation/phy/samsung-usb2.txt +F: drivers/phy/phy-exynos4210-usb2.c +F: drivers/phy/phy-exynos4x12-usb2.c +F: drivers/phy/phy-exynos5250-usb2.c +F: drivers/phy/phy-s5pv210-usb2.c +F: drivers/phy/phy-samsung-usb2.c +F: drivers/phy/phy-samsung-usb2.h + SERIAL DRIVERS M: Greg Kroah-Hartman gre...@linuxfoundation.org L: linux-ser...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] MAINTAINERS: add entry for the Samsung USB2 PHY driver
Signed-off-by: Kamil Debski --- MAINTAINERS | 13 + 1 file changed, 13 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 05dc39d..548602f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7873,6 +7873,19 @@ S: Supported L: net...@vger.kernel.org F: drivers/net/ethernet/samsung/sxgbe/ +SAMSUNG USB2 PHY DRIVER +M: Kamil Debski +L: linux-kernel@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/phy/samsung-phy.txt +F: Documentation/phy/samsung-usb2.txt +F: drivers/phy/phy-exynos4210-usb2.c +F: drivers/phy/phy-exynos4x12-usb2.c +F: drivers/phy/phy-exynos5250-usb2.c +F: drivers/phy/phy-s5pv210-usb2.c +F: drivers/phy/phy-samsung-usb2.c +F: drivers/phy/phy-samsung-usb2.h + SERIAL DRIVERS M: Greg Kroah-Hartman L: linux-ser...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] MAINTAINERS: add entry for the PWM fan driver
Signed-off-by: Kamil Debski --- MAINTAINERS |8 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 548602f..38e4765 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7244,6 +7244,14 @@ T: git git://linuxtv.org/media_tree.git S: Maintained F: drivers/media/usb/pwc/* +PWM FAN DRIVER +M: Kamil Debski +L: lm-sens...@lm-sensors.org +S: Supported +F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt +F: Documentation/hwmon/pwm-fan +F: drivers/hwmon/pwm-fan.c + PWM SUBSYSTEM M: Thierry Reding L: linux-...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] MAINTAINERS: add entry for the PWM fan driver
Signed-off-by: Kamil Debski k.deb...@samsung.com --- MAINTAINERS |8 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 548602f..38e4765 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7244,6 +7244,14 @@ T: git git://linuxtv.org/media_tree.git S: Maintained F: drivers/media/usb/pwc/* +PWM FAN DRIVER +M: Kamil Debski k.deb...@samsung.com +L: lm-sens...@lm-sensors.org +S: Supported +F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt +F: Documentation/hwmon/pwm-fan +F: drivers/hwmon/pwm-fan.c + PWM SUBSYSTEM M: Thierry Reding thierry.red...@gmail.com L: linux-...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] MAINTAINERS: add entry for the Samsung USB2 PHY driver
Signed-off-by: Kamil Debski k.deb...@samsung.com --- MAINTAINERS | 13 + 1 file changed, 13 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 05dc39d..548602f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7873,6 +7873,19 @@ S: Supported L: net...@vger.kernel.org F: drivers/net/ethernet/samsung/sxgbe/ +SAMSUNG USB2 PHY DRIVER +M: Kamil Debski k.deb...@samsung.com +L: linux-kernel@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/phy/samsung-phy.txt +F: Documentation/phy/samsung-usb2.txt +F: drivers/phy/phy-exynos4210-usb2.c +F: drivers/phy/phy-exynos4x12-usb2.c +F: drivers/phy/phy-exynos5250-usb2.c +F: drivers/phy/phy-s5pv210-usb2.c +F: drivers/phy/phy-samsung-usb2.c +F: drivers/phy/phy-samsung-usb2.h + SERIAL DRIVERS M: Greg Kroah-Hartman gre...@linuxfoundation.org L: linux-ser...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: Wednesday, July 16, 2014 3:53 PM > To: Kamil Debski; devicet...@vger.kernel.org; linux- > ker...@vger.kernel.org; lm-sens...@lm-sensors.org > Cc: t.f...@samsung.com; m.szyprow...@samsung.com; tklau...@distanz.ch; > linux-...@vger.kernel.org; varkabhad...@gmail.com > Subject: Re: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver > > Hi Kamil, > > comments inline. Thank you for your review :-) > > Thanks, > Guenter > > On 07/16/2014 03:03 AM, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > Changes since v3: > > - fix missing "\n" in error messages > > - remove of_match_ptr which was not necessary > > - change error returned in case of failed allocation to -ENOMEM > > Changes since v2: > > - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume > > Changes since v1: > > - added documentation to Documentation/hwmon > > - fix checkpatch errors > > - added extra description to Kconfig > > - removed whitespace errors > > - include files rearranged to be in alphabetical order > > - remove unused sysfs entry pwm1_enable > > - changed the behavior of the set_pwm function > > - when 0 PWM value is set pwm_disable is run > > - pwm_config return value is checked for errors > > - use of ATTRIBUTE_GROUPS was added > > - removed "Not enouch memory" error message > > - fixed probe return value in case of devm_of_pwm_get error > > - changed hwmon_device_register_with_groups to > >devm_hwmon_device_register_with_groups > > - changes suspend/resume to use pwm_disable/enable > > - removed unnecessary CONFIG_PM_SLEEP ifdefs > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > Documentation/hwmon/pwm-fan| 17 ++ > > drivers/hwmon/Kconfig | 11 ++ > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 202 > > > 5 files changed, 243 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- > fan.txt > > create mode 100644 Documentation/hwmon/pwm-fan > > create mode 100644 drivers/hwmon/pwm-fan.c > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..610757c > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible : "pwm-fan" > > +- pwms : the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = < 0 1 0>; > > + }; > > diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- > fan > > new file mode 100644 index 000..18529d2 > > --- /dev/null > > +++ b/Documentation/hwmon/pwm-fan > > @@ -0,0 +1,17 @@ > > +Kernel driver pwm-fan > > += > > + > > +This driver enables the use of a PWM module to drive a fan. It uses > > +the generic PWM interface thus it is hardware independent. It can be > > +used on many SoCs, as long as the SoC supplies a PWM line driver > that > > +exposes the generic PWM API. > > + > > +Author: Kamil Debski > > + > > +Description > > +--- > > + > > +The driver implements a simple interface for driving a fan connected > > +to a PWM output. It uses the generic PWM interface, thus it can be > > +used with a range of SoCs. The driver exposes the fan to the user > > +space through the hwmon's sysfs interface. > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index > > 02d3d85..4ac13ab 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > > +
[PATCH v5] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski Reviewed-by: Varka Bhadram Reviewed-by: Tobias Klauser --- Changes since v4: - remove unused variables from pwm_fan_ctx - fixes in the set_pwm function Changes since v3: - fix missing "\n" in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 195 5 files changed, 236 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : "pwm-fan" +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..63076d6 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,195 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can redistribu
RE: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
Hi Varka, Thank you for the review. I agree with your comments in this and your second email. I have just sent an updated version 4 of the patch. Best wishes, -- Kamil Debski Samsung R Institute Poland > -Original Message- > From: Varka Bhadram [mailto:varkabhad...@gmail.com] > Sent: Tuesday, July 15, 2014 2:02 PM > To: Kamil Debski; devicet...@vger.kernel.org; linux- > ker...@vger.kernel.org; lm-sens...@lm-sensors.org > Cc: t.f...@samsung.com; m.szyprow...@samsung.com; li...@roeck-us.net; > tklau...@distanz.ch; linux-...@vger.kernel.org > Subject: Re: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver > > On 07/15/2014 05:21 PM, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all > > PWM devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > Changes since v2: > > - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume > > Changes since v1: > > - added documentation to Documentation/hwmon > > - fix checkpatch errors > > - added extra description to Kconfig > > - removed whitespace errors > > - include files rearranged to be in alphabetical order > > - remove unused sysfs entry pwm1_enable > > - changed the behavior of the set_pwm function > > - when 0 PWM value is set pwm_disable is run > > - pwm_config return value is checked for errors > > - use of ATTRIBUTE_GROUPS was added > > - removed "Not enouch memory" error message > > - fixed probe return value in case of devm_of_pwm_get error > > - changed hwmon_device_register_with_groups to > >devm_hwmon_device_register_with_groups > > - changes suspend/resume to use pwm_disable/enable > > - removed unnecessary CONFIG_PM_SLEEP ifdefs > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > Documentation/hwmon/pwm-fan| 17 ++ > > drivers/hwmon/Kconfig | 11 ++ > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 201 > > > 5 files changed, 242 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- > fan.txt > > create mode 100644 Documentation/hwmon/pwm-fan > > create mode 100644 drivers/hwmon/pwm-fan.c > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..f534607 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible: "pwm-fan" > > +- pwms: the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = < 0 1 0>; > > + }; > > diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- > fan > > new file mode 100644 > > index 000..18529d2 > > --- /dev/null > > +++ b/Documentation/hwmon/pwm-fan > > @@ -0,0 +1,17 @@ > > +Kernel driver pwm-fan > > += > > + > > +This driver enables the use of a PWM module to drive a fan. It uses > the > > +generic PWM interface thus it is hardware independent. It can be > used on > > +many SoCs, as long as the SoC supplies a PWM line driver that > exposes > > +the generic PWM API. > > + > > +Author: Kamil Debski > > + > > +Description > > +--- > > + > > +The driver implements a simple interface for driving a fan connected > to > > +a PWM output. It uses the generic PWM interface, thus it can be used > with > > +a range of SoCs. The driver exposes the fan to the user space > through > > +the hwmon's sysfs interface. > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > > index 02d3d85..4ac13ab 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > > + If you say yes here you get support for fans connected to PWM > lines. > > +
[PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v3: - fix missing "\n" in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 202 5 files changed, 243 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : "pwm-fan" +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..cacb20a --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,202 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of
[PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v3: - fix missing \n in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 202 5 files changed, 243 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : pwm-fan +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..cacb20a --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,202 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option
RE: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
Hi Varka, Thank you for the review. I agree with your comments in this and your second email. I have just sent an updated version 4 of the patch. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Varka Bhadram [mailto:varkabhad...@gmail.com] Sent: Tuesday, July 15, 2014 2:02 PM To: Kamil Debski; devicet...@vger.kernel.org; linux- ker...@vger.kernel.org; lm-sens...@lm-sensors.org Cc: t.f...@samsung.com; m.szyprow...@samsung.com; li...@roeck-us.net; tklau...@distanz.ch; linux-...@vger.kernel.org Subject: Re: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver On 07/15/2014 05:21 PM, Kamil Debski wrote: The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 201 5 files changed, 242 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: pwm-fan +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj
[PATCH v5] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com Reviewed-by: Varka Bhadram varkabhad...@gmail.com Reviewed-by: Tobias Klauser tklau...@distanz.ch --- Changes since v4: - remove unused variables from pwm_fan_ctx - fixes in the set_pwm function Changes since v3: - fix missing \n in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 195 5 files changed, 236 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : pwm-fan +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..63076d6 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,195 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can
RE: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, From: Guenter Roeck [mailto:li...@roeck-us.net] Sent: Wednesday, July 16, 2014 3:53 PM To: Kamil Debski; devicet...@vger.kernel.org; linux- ker...@vger.kernel.org; lm-sens...@lm-sensors.org Cc: t.f...@samsung.com; m.szyprow...@samsung.com; tklau...@distanz.ch; linux-...@vger.kernel.org; varkabhad...@gmail.com Subject: Re: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver Hi Kamil, comments inline. Thank you for your review :-) Thanks, Guenter On 07/16/2014 03:03 AM, Kamil Debski wrote: The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v3: - fix missing \n in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 202 5 files changed, 243 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : pwm-fan +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses +the generic PWM interface thus it is hardware independent. It can be +used on many SoCs, as long as the SoC supplies a PWM line driver that +exposes the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected +to a PWM output. It uses the generic PWM interface, thus it can be +used with a range of SoCs. The driver exposes the fan to the user +space through the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C
[PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 201 5 files changed, 242 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..03d45f2 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,201 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warrant
[PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 201 5 files changed, 242 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: pwm-fan +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..03d45f2 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,201 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty
[PATCH v2] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 5 files changed, 240 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..2bd73c3 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Ge
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi, I forgot to address one of the comments. > From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter > Roeck > Sent: Wednesday, July 09, 2014 6:58 PM > To: Kamil Debski > Cc: devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; lm- > sens...@lm-sensors.org; t.f...@samsung.com; m.szyprow...@samsung.com > Subject: Re: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver > > On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > +static int pwm_fan_remove(struct platform_device *pdev) { > > + struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev); > > + > > + pwm_disable(ctx->pwm); > > Is this needed ? I don't see it used by the leds-pwm driver on cleanup. The pwm-samsung driver does not disable the PWM channel according to my understanding of the code. But for example the pwm-renesas-tpu does stop the PWM timer on free. What is the correct behavior? Is the channel should be disabled on free then I agree that pwm_disable is not necessary. > > + hwmon_device_unregister(ctx->hwmon); > > + > > + return 0; > > +} > > + Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi, I forgot to address one of the comments. From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter Roeck Sent: Wednesday, July 09, 2014 6:58 PM To: Kamil Debski Cc: devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; lm- sens...@lm-sensors.org; t.f...@samsung.com; m.szyprow...@samsung.com Subject: Re: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 snip +static int pwm_fan_remove(struct platform_device *pdev) { + struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev); + + pwm_disable(ctx-pwm); Is this needed ? I don't see it used by the leds-pwm driver on cleanup. The pwm-samsung driver does not disable the PWM channel according to my understanding of the code. But for example the pwm-renesas-tpu does stop the PWM timer on free. What is the correct behavior? Is the channel should be disabled on free then I agree that pwm_disable is not necessary. + hwmon_device_unregister(ctx-hwmon); + + return 0; +} + snip Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed Not enouch memory error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 5 files changed, 240 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: pwm-fan +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski k.deb...@samsung.com + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..2bd73c3 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License
RE: [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Tobias, Thank you for your review. > From: Tobias Klauser [mailto:tklau...@distanz.ch] > Sent: Wednesday, July 09, 2014 7:50 PM > > On 2014-07-09 at 16:53:20 +0200, Kamil Debski > wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > > 4 files changed, 221 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > create mode 100644 drivers/hwmon/pwm-fan.c > > [...] > > > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new > > file mode 100644 index 000..78fa627 > > --- /dev/null > > +++ b/drivers/hwmon/pwm-fan.c > > @@ -0,0 +1,199 @@ > > [...] > > > +#ifdef CONFIG_PM_SLEEP > > +static int pwm_fan_suspend(struct device *dev) { > > + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); > > + > > + return pwm_config(ctx->pwm, 0, ctx->pwm->period); } > > + > > +static int pwm_fan_resume(struct device *dev) { > > + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); > > + > > + return pwm_config(ctx->pwm, ctx->duty_cycle, ctx->pwm->period); } > > + > > +static SIMPLE_DEV_PM_OPS(pwm_fan_pm, pwm_fan_suspend, > > +pwm_fan_resume); > > If you move this out of #ifdef CONFIG_PM_SLEEP, you won't need the > #ifdef around driver.pm below [1]. SIMPLE_DEV_PM_OPS will just define > an empty struct dev_pm_os if CONFIG_PM_LSEEP is not defined. Thanks for this suggestion. > > > +#endif > > + > > + > > + > > +static struct of_device_id of_pwm_fan_match[] = { > > + { .compatible = "pwm-fan", }, > > + {}, > > +}; > > + > > +static struct platform_driver pwm_fan_driver = { > > + .probe = pwm_fan_probe, > > + .remove = pwm_fan_remove, > > + .driver = { > > + .name = "pwm-fan", > > +#ifdef CONFIG_PM_SLEEP > > + .pm = _fan_pm, > > +#endif > > [1] #ifdef CONFIG_PM_SLEEP not needed with the above change. > > > + .of_match_table = of_match_ptr(of_pwm_fan_match), > > + }, > > +}; > > + > > +module_platform_driver(pwm_fan_driver); > > + > > +MODULE_AUTHOR("Kamil Debski "); > > +MODULE_ALIAS("platform:pwm-fan"); > > +MODULE_DESCRIPTION("PWM FAN driver"); MODULE_LICENSE("GPL"); > > -- > > 1.7.9.5 Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, Thank you for your review. > From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter > Roeck > Sent: Wednesday, July 09, 2014 6:58 PM > > On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > > 4 files changed, 221 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > create mode 100644 drivers/hwmon/pwm-fan.c > > Documentation/hwmon/pwm-fan is missing. Ok, I will add it. > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..f534607 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible: "pwm-fan" > > +- pwms: the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = < 0 1 0>; > > + }; > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index > > 08531a1..838ffb8 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > > + If you say yes here you get support for fans connected to PWM > lines. > > + > > + This driver can also be built as a module. If so, the module > > + will be called pwm-fan. > > + > > config SENSORS_SHT15 > > tristate "Sensiron humidity and temperature sensors. SHT15 and > compat." > > depends on GPIOLIB > > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index > > 3dc0f02..3967ecf 100644 > > --- a/drivers/hwmon/Makefile > > +++ b/drivers/hwmon/Makefile > > @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= > ntc_thermistor.o > > obj-$(CONFIG_SENSORS_PC87360) += pc87360.o > > obj-$(CONFIG_SENSORS_PC87427) += pc87427.o > > obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o > > +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o > > obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o > > obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o > > obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o > > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new > > file mode 100644 index 000..78fa627 > > --- /dev/null > > +++ b/drivers/hwmon/pwm-fan.c > > @@ -0,0 +1,199 @@ > > +/* > > + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. > > + * > > + * Copyright (c) 2014 Samsung Electronics Co., Ltd. > > + * > > + * Author: Kamil Debski > > + * > > + * This program is free software; you can redistribute it and/or > > +modify > > + * it under the terms of the GNU General Public License as published > > +by > > + * the Free Software Foundation; either version 2 of the License, or > > + * (at your option) any later version. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + * You should have received a copy of the GNU General Public License > > + * along with this program; if not, write to the Free Software > > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > > +02111-1307 USA > > Please run the patch through checkpatch and ensure that all warnings > and errors are fixed. I did checkpatch with -f by mistake, so it missed this error. Thanks for pointing this out. > > + */ > > + > > +#in
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, Thank you for your review. From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter Roeck Sent: Wednesday, July 09, 2014 6:58 PM On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 drivers/hwmon/pwm-fan.c Documentation/hwmon/pwm-fan is missing. Ok, I will add it. diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: pwm-fan +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 08531a1..838ffb8 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..78fa627 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or +modify + * it under the terms of the GNU General Public License as published +by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA Please run the patch through checkpatch and ensure that all warnings and errors are fixed. I did checkpatch with -f by mistake, so it missed this error. Thanks for pointing this out. + */ + +#include linux/hwmon-sysfs.h +#include linux/hwmon.h +#include linux/module.h +#include linux/mutex.h +#include linux/of.h +#include linux/platform_device.h +#include linux/pwm.h For new drivers, please list include files in alphabetic order. Ok. + +#define MAX_PWM 255 + +struct pwm_fan_ctx { + struct device *hwmon; + struct mutex lock; + struct platform_device *pdev; + struct pwm_device *pwm; + unsigned int duty_cycle; + unsigned char pwm_value; +}; + +static ssize_t show_pwm_enable(struct device *dev, + struct device_attribute *attr, char *buf) { + /* For the sake of simplicity only mode 1 (PWM) is supported */ + return sprintf(buf, 1\n); +} + +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count
RE: [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Tobias, Thank you for your review. From: Tobias Klauser [mailto:tklau...@distanz.ch] Sent: Wednesday, July 09, 2014 7:50 PM On 2014-07-09 at 16:53:20 +0200, Kamil Debski k.deb...@samsung.com wrote: The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 drivers/hwmon/pwm-fan.c [...] diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..78fa627 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ [...] +#ifdef CONFIG_PM_SLEEP +static int pwm_fan_suspend(struct device *dev) { + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + + return pwm_config(ctx-pwm, 0, ctx-pwm-period); } + +static int pwm_fan_resume(struct device *dev) { + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + + return pwm_config(ctx-pwm, ctx-duty_cycle, ctx-pwm-period); } + +static SIMPLE_DEV_PM_OPS(pwm_fan_pm, pwm_fan_suspend, +pwm_fan_resume); If you move this out of #ifdef CONFIG_PM_SLEEP, you won't need the #ifdef around driver.pm below [1]. SIMPLE_DEV_PM_OPS will just define an empty struct dev_pm_os if CONFIG_PM_LSEEP is not defined. Thanks for this suggestion. +#endif + + + +static struct of_device_id of_pwm_fan_match[] = { + { .compatible = pwm-fan, }, + {}, +}; + +static struct platform_driver pwm_fan_driver = { + .probe = pwm_fan_probe, + .remove = pwm_fan_remove, + .driver = { + .name = pwm-fan, +#ifdef CONFIG_PM_SLEEP + .pm = pwm_fan_pm, +#endif [1] #ifdef CONFIG_PM_SLEEP not needed with the above change. + .of_match_table = of_match_ptr(of_pwm_fan_match), + }, +}; + +module_platform_driver(pwm_fan_driver); + +MODULE_AUTHOR(Kamil Debski k.deb...@samsung.com); +MODULE_ALIAS(platform:pwm-fan); +MODULE_DESCRIPTION(PWM FAN driver); MODULE_LICENSE(GPL); -- 1.7.9.5 Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] hwmon: gpio-fan: Change name passed to hwmon_device_register_with_groups
Commit 648cd48c9e566f53c5df30d79857e0937ae13b09 (hwmon: Do not accept invalid name attributes) added check for "-" in the name of hwmon device. This patch changes the name supplied by gpio-fan so that it is accepted by hwmon. Signed-off-by: Kamil Debski --- drivers/hwmon/gpio-fan.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index ba35e4d..5acd555 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -538,7 +538,7 @@ static int gpio_fan_probe(struct platform_device *pdev) /* Make this driver part of hwmon class. */ fan_data->hwmon_dev = hwmon_device_register_with_groups(>dev, - "gpio-fan", fan_data, + "gpiofan", fan_data, gpio_fan_groups); if (IS_ERR(fan_data->hwmon_dev)) return PTR_ERR(fan_data->hwmon_dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = < 0 1 0>; + }; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 08531a1..838ffb8 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..78fa627 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAX_PWM 255 + +struct pwm_fan_ctx { + struct device *hwmon; + struct mutex lock; + struct platform_device *pdev; + struct pwm_device *pwm; + unsigned int duty_cycle; + unsigned char pwm_value; +}; + +static ssize_t show_pwm_enable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* For the sake of simplicity only mode 1 (PWM) is supported */ + return sprintf(buf, "1\n"); +} + +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + unsigned long pwm, duty; + + if (kstrtoul(buf, 10, ) || pwm > MAX_PWM) + return -EINVAL; + + mutex_lock(>lock); + + if (ctx->pwm_value == pwm) + goto exit_set_pwm; + + duty = DIV_ROUND_UP(pwm * (ctx->pwm->period - 1), MAX_PWM); + if (pwm_config(ctx->pwm, duty, ctx->pwm->period)) + goto exit_set_pwm; + + ctx->duty_cycle = duty; + ctx->pwm_value = pwm; + + +exit_set_pwm: + mutex_unlock(>lock); + + return count; +} + +static ssize_t show_pwm(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pwm_fan_ctx *ctx = dev_get_drv
[PATCH] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: pwm-fan +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = pwm-fan; + status = okay; + pwms = pwm 0 1 0; + }; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 08531a1..838ffb8 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate PWM fan + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate Sensiron humidity and temperature sensors. SHT15 and compat. depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..78fa627 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include linux/hwmon-sysfs.h +#include linux/hwmon.h +#include linux/module.h +#include linux/mutex.h +#include linux/of.h +#include linux/platform_device.h +#include linux/pwm.h + +#define MAX_PWM 255 + +struct pwm_fan_ctx { + struct device *hwmon; + struct mutex lock; + struct platform_device *pdev; + struct pwm_device *pwm; + unsigned int duty_cycle; + unsigned char pwm_value; +}; + +static ssize_t show_pwm_enable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* For the sake of simplicity only mode 1 (PWM) is supported */ + return sprintf(buf, 1\n); +} + +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + unsigned long pwm, duty; + + if (kstrtoul(buf, 10, pwm) || pwm MAX_PWM) + return -EINVAL; + + mutex_lock(ctx-lock); + + if (ctx-pwm_value == pwm) + goto exit_set_pwm; + + duty = DIV_ROUND_UP(pwm * (ctx-pwm-period - 1), MAX_PWM); + if (pwm_config(ctx-pwm, duty, ctx-pwm-period)) + goto exit_set_pwm; + + ctx-duty_cycle = duty; + ctx-pwm_value = pwm; + + +exit_set_pwm: + mutex_unlock(ctx-lock); + + return count; +} + +static ssize_t show_pwm(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct
[PATCH] hwmon: gpio-fan: Change name passed to hwmon_device_register_with_groups
Commit 648cd48c9e566f53c5df30d79857e0937ae13b09 (hwmon: Do not accept invalid name attributes) added check for - in the name of hwmon device. This patch changes the name supplied by gpio-fan so that it is accepted by hwmon. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/hwmon/gpio-fan.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index ba35e4d..5acd555 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -538,7 +538,7 @@ static int gpio_fan_probe(struct platform_device *pdev) /* Make this driver part of hwmon class. */ fan_data-hwmon_dev = hwmon_device_register_with_groups(pdev-dev, - gpio-fan, fan_data, + gpiofan, fan_data, gpio_fan_groups); if (IS_ERR(fan_data-hwmon_dev)) return PTR_ERR(fan_data-hwmon_dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-exynos5250-usb2.c |2 - drivers/phy/phy-samsung-usb2.h|3 +- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..63134d8 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv->reg_phy + EXYNOS_4x12_UPHYCLK); clk &= ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv->ref_reg_val << EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv->reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst->cfg->id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv->reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv->reg_phy + EXYNOS_4x12_UPHYPWR); pwr &= ~phypwr; writel(pwr, drv->reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_int(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst->drv; + if (inst->int_cnt++ > 0) + return; - inst->enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(ins
[PATCH v2] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-exynos5250-usb2.c |2 - drivers/phy/phy-samsung-usb2.h|3 +- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..63134d8 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv-reg_phy + EXYNOS_4x12_UPHYCLK); clk = ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv-ref_reg_val EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv-reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst-cfg-id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv-reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv-reg_phy + EXYNOS_4x12_UPHYPWR); pwr = ~phypwr; writel(pwr, drv-reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_int(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst-drv; + if (inst-int_cnt++ 0) + return; - inst-enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(inst, 1); +} + +static int exynos4x12_power_on(struct
RE: [PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
Hi Daniel, > From: Daniel Drake [mailto:dr...@endlessm.com] > Sent: Tuesday, June 24, 2014 5:09 PM > > On Tue, Jun 24, 2014 at 1:54 PM, Kamil Debski > wrote: > > The Exynos4412 USB 2.0 PHY hardware differs from the description > > provided in the documentation. Some register bits have different > > function. This patch fixes the defines of register bits and changes > > the way how phys are powered on and off. > > I guess this replaces the patch titled "drivers: phy: exynos4x12-phy: > fix HSIC1 power on/off sequence" Yes, indeed it replaces this patch. I did some more research on how the hardware actually behaves. > > Tested on ODROID-U2. Seems to be working as well as the previous patch: Thank you very much for testing. > - Internal SMSC hub works on boot and after reboot, tested with USB > mouse > - Internal SMSC ethernet device works on boot, but disappears upon > reboot. (same as previous patch, also reproduced by Marek) By reboot I guess that you mean typing "reboot" or by using SysRq magic and not power cycling? If so, I had experienced the same symptoms. I guess that the Ethernet chip is not reset properly and fails to enumerate without power cycling (it's nRESET pin is connected to P3V3). I found that removing regulator-always-on from buck8_reg: BUCK8 in the dts file fixes this problem. Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-samsung-usb2.h|3 +- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..59d8dd3 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv->reg_phy + EXYNOS_4x12_UPHYCLK); clk &= ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv->ref_reg_val << EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv->reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst->cfg->id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1 ; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv->reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv->reg_phy + EXYNOS_4x12_UPHYPWR); pwr &= ~phypwr; writel(pwr, drv->reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_internal(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst->drv; + if (inst->int_cnt++ > 0) + return; - inst->enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(inst, 1); +} + +static int exynos4x12_power_on(struct
[PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-samsung-usb2.h|3 +- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..59d8dd3 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv-reg_phy + EXYNOS_4x12_UPHYCLK); clk = ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv-ref_reg_val EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv-reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst-cfg-id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1 ; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv-reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv-reg_phy + EXYNOS_4x12_UPHYPWR); pwr = ~phypwr; writel(pwr, drv-reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_internal(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst-drv; + if (inst-int_cnt++ 0) + return; - inst-enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(inst, 1); +} + +static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +{ + struct
RE: [PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
Hi Daniel, From: Daniel Drake [mailto:dr...@endlessm.com] Sent: Tuesday, June 24, 2014 5:09 PM On Tue, Jun 24, 2014 at 1:54 PM, Kamil Debski k.deb...@samsung.com wrote: The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. I guess this replaces the patch titled drivers: phy: exynos4x12-phy: fix HSIC1 power on/off sequence Yes, indeed it replaces this patch. I did some more research on how the hardware actually behaves. Tested on ODROID-U2. Seems to be working as well as the previous patch: Thank you very much for testing. - Internal SMSC hub works on boot and after reboot, tested with USB mouse - Internal SMSC ethernet device works on boot, but disappears upon reboot. (same as previous patch, also reproduced by Marek) By reboot I guess that you mean typing reboot or by using SysRq magic and not power cycling? If so, I had experienced the same symptoms. I guess that the Ethernet chip is not reset properly and fails to enumerate without power cycling (it's nRESET pin is connected to P3V3). I found that removing regulator-always-on from buck8_reg: BUCK8 in the dts file fixes this problem. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: exynos: fix building as a module
Hi Arnd, > From: Arnd Bergmann [mailto:a...@arndb.de] > Sent: Wednesday, March 12, 2014 4:48 PM > > The top-level phy-samsung-usb2 driver may be configured as a loadable > module, which currently causes link errors because of the dependency on > the exynos{5250,4x12,4210}_usb2_phy_config > symbol. Solving this could be achieved by exporting these symbols, but > as the SoC-specific parts of the driver are not currently built as > modules, it seems better to just link everything into one module and > avoid the need for the export. Thank you for this patch and spotting this error. Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R Institute Poland > > Signed-off-by: Arnd Bergmann > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > 2faf78e..7728518 100644 > --- a/drivers/phy/Makefile > +++ b/drivers/phy/Makefile > @@ -13,8 +13,9 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o > obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o > obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o > obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o > -obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o > -obj-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o > -obj-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o > -obj-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o > +obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o > +phy-exynos-usb2-y+= phy-samsung-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o > obj-$(CONFIG_PHY_XGENE) += phy-xgene.o -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: exynos: fix building as a module
Hi Arnd, From: Arnd Bergmann [mailto:a...@arndb.de] Sent: Wednesday, March 12, 2014 4:48 PM The top-level phy-samsung-usb2 driver may be configured as a loadable module, which currently causes link errors because of the dependency on the exynos{5250,4x12,4210}_usb2_phy_config symbol. Solving this could be achieved by exporting these symbols, but as the SoC-specific parts of the driver are not currently built as modules, it seems better to just link everything into one module and avoid the need for the export. Thank you for this patch and spotting this error. Acked-by: Kamil Debski k.deb...@samsung.com Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: Arnd Bergmann a...@arndb.de diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 2faf78e..7728518 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -13,8 +13,9 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o -obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o -obj-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o -obj-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o -obj-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o +obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o +phy-exynos-usb2-y+= phy-samsung-usb2.o +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1097 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = < 305>, < 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <_reg>; + samsung,pmureg-phandle = <_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = < 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..ed12d43 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,135 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on
[PATCH v10 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 404 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 424 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3374836..1b607d7 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -136,4 +136,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c4ddd23..ecf0d3f 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..94179af --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,404 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v10 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, ); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(>dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the tenth version of this patchset. The only difference since v9 is correction in the documentation. Best wishes, Kamil Debski -- Changes from v9: 1) phy: core: Add an exported of_phy_get function - No changes since v9. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v9. 3) phy: Add new Exynos USB 2.0 PHY driver - Fixed missing callback in the documentation of the samsung_usb2_phy_config structure. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - No changes since v9. -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci
RE: [PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Anton, Kishon, > From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com] > Sent: Thursday, March 06, 2014 9:26 AM > > Hi Kamil, > > ... > > > +| 3. Supporting SoCs > > ++ > > + > > +To support a new SoC a new file should be added to the drivers/phy > > +directory. Each SoC's configuration is stored in an instance of the > > +struct samsung_usb2_phy_config. > > + > > +struct samsung_usb2_phy_config { > > + const struct samsung_usb2_common_phy *phys; > > + unsigned int num_phys; > > + bool has_mode_switch; > > You missed rate_to_clk here. Thank you for spotting this. Kishon: I am sorry that this omission was made. I am happy to send an updated patchset. However, I want to give some time for any additional comments. Do you think that we have for this? Is today evening ok with you? > > > +}; > > + > > ... > > > diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- > samsung- > > usb2.c new file mode 100644 index 000..c3b7719 > > --- /dev/null > > +++ b/drivers/phy/phy-samsung-usb2.c > > @@ -0,0 +1,222 @@ > > +/* > > + * Samsung SoC USB 1.1/2.0 PHY driver > > + * > > + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > > + * Author: Kamil Debski > > + * > > + * This program is free software; you can redistribute it and/or > > modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "phy-samsung-usb2.h" > > + > > +static int samsung_usb2_phy_power_on(struct phy *phy) { > > + struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy); > > + struct samsung_usb2_phy_driver *drv = inst->drv; > > + int ret; > > + > > + dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n", > > + inst->cfg->label); > > + ret = clk_prepare_enable(drv->clk); > > clk_prepare_enable() can sleep, and therefore doesn't allow > samusng_usb2_phy_power_on() to be used in atomic context (e.g. inside > spin_lock-ed area), what sometimes may be desirable. > What about to prepare clock in probe, and just enable it here > (note: clk_enable() doesn't sleep). >From the onward discussion between you and Kishon, I draw the conclusion that this change is not necessary. Right? > > > + if (ret) > > + goto err_main_clk; > > + ret = clk_prepare_enable(drv->ref_clk); > > + if (ret) > > + goto err_instance_clk; > > + if (inst->cfg->power_on) { > > + spin_lock(>lock); > > + ret = inst->cfg->power_on(inst); > > + spin_unlock(>lock); > > + } > > + > > + return 0; > > Thank you Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Tobias, > From: Tobias Jakobi [mailto:tjak...@math.uni-bielefeld.de] > Sent: Thursday, March 06, 2014 12:08 AM > > Hello Kamil, > > this looks very good. I just tested the patchset on my ODROID-X2 > (Exynos4412-based board) and the USB stability issues I mentioned to > you before (with the older patchset) seem to be gone. This problem was related to the reset procedure not being done completely. It is corrected now. > > All devices on the USB behave normally (mass storage, ethernet and > bluetooth). Thank you for testing these patches. Would you consider adding a "Tested-by" tag? I am planning to send v10 soon, which will address comments to v9. > > With best wishes, > Tobias Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Tobias, From: Tobias Jakobi [mailto:tjak...@math.uni-bielefeld.de] Sent: Thursday, March 06, 2014 12:08 AM Hello Kamil, this looks very good. I just tested the patchset on my ODROID-X2 (Exynos4412-based board) and the USB stability issues I mentioned to you before (with the older patchset) seem to be gone. This problem was related to the reset procedure not being done completely. It is corrected now. All devices on the USB behave normally (mass storage, ethernet and bluetooth). Thank you for testing these patches. Would you consider adding a Tested-by tag? I am planning to send v10 soon, which will address comments to v9. With best wishes, Tobias Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Anton, Kishon, From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com] Sent: Thursday, March 06, 2014 9:26 AM Hi Kamil, ... +| 3. Supporting SoCs ++ + +To support a new SoC a new file should be added to the drivers/phy +directory. Each SoC's configuration is stored in an instance of the +struct samsung_usb2_phy_config. + +struct samsung_usb2_phy_config { + const struct samsung_usb2_common_phy *phys; + unsigned int num_phys; + bool has_mode_switch; You missed rate_to_clk here. Thank you for spotting this. Kishon: I am sorry that this omission was made. I am happy to send an updated patchset. However, I want to give some time for any additional comments. Do you think that we have for this? Is today evening ok with you? +}; + ... diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- samsung- usb2.c new file mode 100644 index 000..c3b7719 --- /dev/null +++ b/drivers/phy/phy-samsung-usb2.c @@ -0,0 +1,222 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/clk.h +#include linux/mfd/syscon.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h +#include phy-samsung-usb2.h + +static int samsung_usb2_phy_power_on(struct phy *phy) { + struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy); + struct samsung_usb2_phy_driver *drv = inst-drv; + int ret; + + dev_dbg(drv-dev, Request to power_on \%s\ usb phy\n, + inst-cfg-label); + ret = clk_prepare_enable(drv-clk); clk_prepare_enable() can sleep, and therefore doesn't allow samusng_usb2_phy_power_on() to be used in atomic context (e.g. inside spin_lock-ed area), what sometimes may be desirable. What about to prepare clock in probe, and just enable it here (note: clk_enable() doesn't sleep). From the onward discussion between you and Kishon, I draw the conclusion that this change is not necessary. Right? + if (ret) + goto err_main_clk; + ret = clk_prepare_enable(drv-ref_clk); + if (ret) + goto err_instance_clk; + if (inst-cfg-power_on) { + spin_lock(drv-lock); + ret = inst-cfg-power_on(inst); + spin_unlock(drv-lock); + } + + return 0; Thank you Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the tenth version of this patchset. The only difference since v9 is correction in the documentation. Best wishes, Kamil Debski -- Changes from v9: 1) phy: core: Add an exported of_phy_get function - No changes since v9. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v9. 3) phy: Add new Exynos USB 2.0 PHY driver - Fixed missing callback in the documentation of the samsung_usb2_phy_config structure. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - No changes since v9. -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single ref clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single ref clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI - HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg - *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided
[PATCH v10 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells, + ret = of_parse_phandle_with_args(np, phys, #phy-cells, index, args); - if (ret) { - dev_dbg(dev, failed to get phy in %s node\n, - dev-of_node-full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, phy-names, con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy-ops-owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(phy-dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev-of_node) { index = of_property_match_string(dev-of_node, phy-names, string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev-of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 404 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 424 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - samsung,exynos4210-usb2-phy - samsung,exynos4x12-usb2-phy + - samsung,exynos5250-usb2-phy - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3374836..1b607d7 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -136,4 +136,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool Support for Exynos 5250 + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c4ddd23..ecf0d3f 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..94179af --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,404 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/delay.h +#include linux/io.h +#include linux/phy/phy.h +#include linux/regmap.h +#include phy-samsung-usb2.h + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND BIT(4) +#define
[PATCH v10 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1097 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - samsung,exynos4210-usb2-phy + - samsung,exynos4x12-usb2-phy +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the phy clock is required by the phy module, used as a gate + - the ref clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device (device), + 1 - USB host (host), + 2 - HSIC0 (hsic0), + 3 - HSIC1 (hsic1), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125b 0x100; + clocks = clock 305, clock 2; + clock-names = phy, ref; + status = okay; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = usbphy 2; + phy-names = phy; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..ed12d43 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,135 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on which SoC was chosen they execute SoC + specific callbacks. The specific SoC version is selected by choosing + the appropriate compatible string. In addition, this file contains
[PATCH v9 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 404 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 424 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index fc5a44a..c206e25 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0ea36ff..f76c239 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..94179af --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,404 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v9 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1096 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = < 305>, < 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <_reg>; + samsung,pmureg-phandle = <_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = < 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on
[PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the ninth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. v9 brings whitespace corrections compared to v8. Best wishes, Kamil Debski -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy frame
[PATCH v9 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, ); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(>dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 405 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 425 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index fc5a44a..c206e25 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0ea36ff..f76c239 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..877994e --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,405 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v8 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 329 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1100 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = < 305>, < 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <_reg>; + samsung,pmureg-phandle = <_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = < 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on
[PATCH v8 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, ); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(>dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the eighth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. Best wishes, Kamil Debski -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy->otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB PHY driver
RE: [PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Sander, > From: Kamil Debski [mailto:k.deb...@samsung.com] > Sent: Tuesday, March 04, 2014 4:24 PM > > Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the > generic PHY framework. The driver includes support for the Exynos 4210 > and 4x12 SoC families. > > Signed-off-by: Kamil Debski Sander, you did test the v6 of this patch, thus I am adding your "Tested-by". Could you confirm that this version works as well? Tested-by: Sander Hollaar Best wishes, -- Kamil Debski Samsung R Institute Poland > --- > .../devicetree/bindings/phy/samsung-phy.txt| 53 > Documentation/phy/samsung-usb2.txt | 134 > drivers/phy/Kconfig| 29 ++ > drivers/phy/Makefile |3 + > drivers/phy/phy-exynos4210-usb2.c | 262 > > drivers/phy/phy-exynos4x12-usb2.c | 330 > > drivers/phy/phy-samsung-usb2.c | 223 > + > drivers/phy/phy-samsung-usb2.h | 67 > 8 files changed, 1101 insertions(+) > create mode 100644 Documentation/phy/samsung-usb2.txt > create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode > 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 > drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy- > samsung-usb2.h > > diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt > b/Documentation/devicetree/bindings/phy/samsung-phy.txt > index c0fccaa..bf955ab 100644 > --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt > +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt > @@ -20,3 +20,56 @@ Required properties: > - compatible : should be "samsung,exynos5250-dp-video-phy"; > - reg : offset and length of the Display Port PHY register set; > - #phy-cells : from the generic PHY bindings, must be 0; > + > +Samsung S5P/EXYNOS SoC series USB PHY > +- > + > +Required properties: > +- compatible : should be one of the listed compatibles: > + - "samsung,exynos4210-usb2-phy" > + - "samsung,exynos4x12-usb2-phy" > +- reg : a list of registers used by phy driver > + - first and obligatory is the location of phy modules registers > +- samsung,sysreg-phandle - handle to syscon used to control the system > +registers > +- samsung,pmureg-phandle - handle to syscon used to control PMU > +registers > +- #phy-cells : from the generic phy bindings, must be 1; > +- clocks and clock-names: > + - the "phy" clock is required by the phy module, used as a gate > + - the "ref" clock is used to get the rate of the clock provided > to the > + PHY module > + > +The first phandle argument in the PHY specifier identifies the PHY, > its > +meaning is compatible dependent. For the currently supported SoCs > +(Exynos 4210 and Exynos 4212) it is as follows: > + 0 - USB device ("device"), > + 1 - USB host ("host"), > + 2 - HSIC0 ("hsic0"), > + 3 - HSIC1 ("hsic1"), > + > +Exynos 4210 and Exynos 4212 use mode switching and require that mode > +switch register is supplied. > + > +Example: > + > +For Exynos 4412 (compatible with Exynos 4212): > + > +usbphy: phy@125b { > + compatible = "samsung,exynos4x12-usb2-phy"; > + reg = <0x125b 0x100>; > + clocks = < 305>, < 2>; > + clock-names = "phy", "ref"; > + status = "okay"; > + #phy-cells = <1>; > + samsung,sysreg-phandle = <_reg>; > + samsung,pmureg-phandle = <_reg>; > +}; > + > +Then the PHY can be used in other nodes such as: > + > +phy-consumer@1234 { > + phys = < 2>; > + phy-names = "phy"; > +}; > + > +Refer to DT bindings documentation of particular PHY consumer devices > +for more information about required PHYs and the way of specification. > diff --git a/Documentation/phy/samsung-usb2.txt > b/Documentation/phy/samsung-usb2.txt > new file mode 100644 > index 000..0c8e260 > --- /dev/null > +++ b/Documentation/phy/samsung-usb2.txt > @@ -0,0 +1,134 @@ > +.- > - > ++ > +|Samsung USB 2.0 PHY adaptation layer > | > ++- > +' > + > +| 1. Description > ++ > + > +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar > +among many SoCs. In spite
RE: [PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Sander, From: Kamil Debski [mailto:k.deb...@samsung.com] Sent: Tuesday, March 04, 2014 4:24 PM Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4210 and 4x12 SoC families. Signed-off-by: Kamil Debski k.deb...@samsung.com Sander, you did test the v6 of this patch, thus I am adding your Tested-by. Could you confirm that this version works as well? Tested-by: Sander Hollaar san...@humilis.net Best wishes, -- Kamil Debski Samsung RD Institute Poland --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 330 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1101 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy- samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - samsung,exynos4210-usb2-phy + - samsung,exynos4x12-usb2-phy +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system +registers +- samsung,pmureg-phandle - handle to syscon used to control PMU +registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the phy clock is required by the phy module, used as a gate + - the ref clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs +(Exynos 4210 and Exynos 4212) it is as follows: + 0 - USB device (device), + 1 - USB host (host), + 2 - HSIC0 (hsic0), + 3 - HSIC1 (hsic1), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode +switch register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125b 0x100; + clocks = clock 305, clock 2; + clock-names = phy, ref; + status = okay; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = usbphy 2; + phy-names = phy; +}; + +Refer to DT bindings documentation of particular PHY consumer devices +for more information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.- - ++ +|Samsung USB 2.0 PHY adaptation layer | ++- +' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often the +differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes +or the PHY powering up process had to be altered. This adaptation layer +is a compromise between having separate drivers and having a single +driver with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function
[PATCH v8 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the eighth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. Best wishes, Kamil Debski -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single ref clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single ref clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI - HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg - *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy-otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB PHY driver - include files cleanup - use BIT(x) macro
[PATCH v8 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells, + ret = of_parse_phandle_with_args(np, phys, #phy-cells, index, args); - if (ret) { - dev_dbg(dev, failed to get phy in %s node\n, - dev-of_node-full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, phy-names, con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy-ops-owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(phy-dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev-of_node) { index = of_property_match_string(dev-of_node, phy-names, string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev-of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 329 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1100 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - samsung,exynos4210-usb2-phy + - samsung,exynos4x12-usb2-phy +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the phy clock is required by the phy module, used as a gate + - the ref clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device (device), + 1 - USB host (host), + 2 - HSIC0 (hsic0), + 3 - HSIC1 (hsic1), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125b 0x100; + clocks = clock 305, clock 2; + clock-names = phy, ref; + status = okay; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = usbphy 2; + phy-names = phy; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on which SoC was chosen they execute SoC + specific callbacks. The specific SoC version is selected by choosing + the appropriate compatible string. In addition, this file contains
[PATCH v8 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 405 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 425 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - samsung,exynos4210-usb2-phy - samsung,exynos4x12-usb2-phy + - samsung,exynos5250-usb2-phy - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index fc5a44a..c206e25 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool Support for Exynos 5250 + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0ea36ff..f76c239 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..877994e --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,405 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski k.deb...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/delay.h +#include linux/io.h +#include linux/phy/phy.h +#include linux/regmap.h +#include phy-samsung-usb2.h + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND BIT(4) +#define
[PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1096 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - samsung,exynos4210-usb2-phy + - samsung,exynos4x12-usb2-phy +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the phy clock is required by the phy module, used as a gate + - the ref clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device (device), + 1 - USB host (host), + 2 - HSIC0 (hsic0), + 3 - HSIC1 (hsic1), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125b 0x100; + clocks = clock 305, clock 2; + clock-names = phy, ref; + status = okay; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = usbphy 2; + phy-names = phy; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on which SoC was chosen they execute SoC + specific callbacks. The specific SoC version is selected by choosing + the appropriate compatible string. In addition, this file contains
[PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the ninth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. v9 brings whitespace corrections compared to v8. Best wishes, Kamil Debski -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single ref clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single ref clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI - HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg - *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy-otg in order
[PATCH v9 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/