Re: [PATCHv9 14/15] cec: s5p-cec: Add s5p-cec driver
Hi, On 12 October 2015 at 12:50, Hans Verkuilwrote: > On 10/06/2015 12:32 AM, Russell King - ARM Linux wrote: >> On Mon, Sep 07, 2015 at 03:44:43PM +0200, Hans Verkuil wrote: >>> +if (status & CEC_STATUS_TX_DONE) { >>> +if (status & CEC_STATUS_TX_ERROR) { >>> +dev_dbg(cec->dev, "CEC_STATUS_TX_ERROR set\n"); >>> +cec->tx = STATE_ERROR; >>> +} else { >>> +dev_dbg(cec->dev, "CEC_STATUS_TX_DONE\n"); >>> +cec->tx = STATE_DONE; >>> +} >>> +s5p_clr_pending_tx(cec); >>> +} >> >> Your CEC implementation seems to be written around the idea that there >> are only two possible outcomes from a CEC message - "done" and "error", >> which get translated to: > > This code is for the Samsung exynos CEC implementation. Marek, is this all > that the exynos CEC hardware returns? The possible status values that are implemented in the CEC framework are following: +/* cec status field */ +#define CEC_TX_STATUS_OK (0) +#define CEC_TX_STATUS_ARB_LOST (1 << 0) +#define CEC_TX_STATUS_RETRY_TIMEOUT(1 << 1) +#define CEC_TX_STATUS_FEATURE_ABORT(1 << 2) +#define CEC_TX_STATUS_REPLY_TIMEOUT(1 << 3) +#define CEC_RX_STATUS_READY(0) The only two ones I could match with the Exynos CEC module status bits are CEC_TX_STATUS_OK and CEC_TX_STATUS_RETRY_TIMEOUT. The status bits in Exynos HW are: - Tx_Error - Tx_Done - Tx_Transferring - Tx_Running - Tx_Bytes_Transferred - Tx_Wait - Tx_Sending_Status_Bit - Tx_Sending_Hdr_Blk - Tx_Sending_Data_Blk - Tx_Latest_Initiator - Tx_Wait_SFT_Succ - Tx_Wait_SFT_New - Tx_Wait_SFT_Retran - Tx_Retrans_Cnt - Tx_ACK_Failed > >> >>> +case STATE_DONE: >>> +cec_transmit_done(cec->adap, CEC_TX_STATUS_OK); >>> +cec->tx = STATE_IDLE; >>> +break; >>> +case STATE_ERROR: >>> +cec_transmit_done(cec->adap, CEC_TX_STATUS_RETRY_TIMEOUT); >>> +cec->tx = STATE_IDLE; >> >> "okay" and "retry_timeout". So, if we have an adapter which can report >> (eg) a NACK, we have to report it as the obscure "retry timeout" status? >> Why this obscure naming - why can't we have something that uses the >> terminology in the spec? >> > > Actually, a NACK should lead to a re-transmission (up to 5 times), see CEC > 7.1. > The assumption of the CEC framework is that this is done by the CEC adapter > driver, not by the framework. So if after repeated retransmissions there is > still no Ack, the CEC_TX_STATUS_RETRY_TIMEOUT error is returned. I could > change this to _MAX_RETRIES_REACHED if you prefer. > > The CEC_TX_STATUS_ macros were based on what the adv drivers support (except > for CEC_TX_STATUS_REPLY_TIMEOUT which is specific to the framework). > > Regards, > > Hans Best wishes, Kamil -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv9 14/15] cec: s5p-cec: Add s5p-cec driver
Hi, On 12 October 2015 at 14:39, Hans Verkuil <hverk...@xs4all.nl> wrote: > On 10/12/2015 02:33 PM, Kamil Debski wrote: >> Hi, >> >> On 12 October 2015 at 12:50, Hans Verkuil <hverk...@xs4all.nl> wrote: >>> On 10/06/2015 12:32 AM, Russell King - ARM Linux wrote: >>>> On Mon, Sep 07, 2015 at 03:44:43PM +0200, Hans Verkuil wrote: >>>>> +if (status & CEC_STATUS_TX_DONE) { >>>>> +if (status & CEC_STATUS_TX_ERROR) { >>>>> +dev_dbg(cec->dev, "CEC_STATUS_TX_ERROR set\n"); >>>>> +cec->tx = STATE_ERROR; >>>>> +} else { >>>>> +dev_dbg(cec->dev, "CEC_STATUS_TX_DONE\n"); >>>>> +cec->tx = STATE_DONE; >>>>> +} >>>>> +s5p_clr_pending_tx(cec); >>>>> +} >>>> >>>> Your CEC implementation seems to be written around the idea that there >>>> are only two possible outcomes from a CEC message - "done" and "error", >>>> which get translated to: >>> >>> This code is for the Samsung exynos CEC implementation. Marek, is this all >>> that the exynos CEC hardware returns? >> >> The possible status values that are implemented in the CEC framework >> are following: >> >> +/* cec status field */ >> +#define CEC_TX_STATUS_OK (0) >> +#define CEC_TX_STATUS_ARB_LOST (1 << 0) >> +#define CEC_TX_STATUS_RETRY_TIMEOUT(1 << 1) >> +#define CEC_TX_STATUS_FEATURE_ABORT(1 << 2) >> +#define CEC_TX_STATUS_REPLY_TIMEOUT(1 << 3) >> +#define CEC_RX_STATUS_READY(0) >> >> The only two ones I could match with the Exynos CEC module status bits are >> CEC_TX_STATUS_OK and CEC_TX_STATUS_RETRY_TIMEOUT. >> >> The status bits in Exynos HW are: >> - Tx_Error >> - Tx_Done >> - Tx_Transferring >> - Tx_Running >> - Tx_Bytes_Transferred >> >> - Tx_Wait >> - Tx_Sending_Status_Bit >> - Tx_Sending_Hdr_Blk >> - Tx_Sending_Data_Blk >> - Tx_Latest_Initiator >> >> - Tx_Wait_SFT_Succ >> - Tx_Wait_SFT_New >> - Tx_Wait_SFT_Retran >> - Tx_Retrans_Cnt >> - Tx_ACK_Failed > > So are these all intermediate states? And every transfer always ends with > Tx_Done or > Tx_Error state? Yes, the Exynos CEC module has a pretty low level status indicator. > It does look that way... > > Regards, > > Hans > Best wishes, Kamil [snip] -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2 1/2] s5p-mfc: end-of-stream handling for newer encoders
"enc src y addr: 0x%08lx\n", > src_y_addr); > + mfc_debug(2, "enc src c addr: 0x%08lx\n", > src_c_addr); > > - s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr); > + s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, > src_c_addr); > + if (src_mb->flags & MFC_BUF_FLAG_EOS) > + ctx->state = MFCINST_FINISHING; > + } > + } > > dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); > dst_mb->flags |= MFC_BUF_FLAG_USED; > @@ -1639,11 +1657,10 @@ static inline void s5p_mfc_run_init_dec(struct > s5p_mfc_ctx *ctx) > spin_lock_irqsave(>irqlock, flags); > mfc_debug(2, "Preparing to init decoding.\n"); > temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); > - mfc_debug(2, "Header size: %d\n", > - temp_vb->b->vb2_buf.planes[0].bytesused); > + mfc_debug(2, "Header size: %d\n", > +temp_vb->b->vb2_buf.planes[0].bytesused); > s5p_mfc_set_dec_stream_buffer_v6(ctx, > vb2_dma_contig_plane_dma_addr(_vb->b->vb2_buf, > 0), 0, > - temp_vb->b->vb2_buf.planes[0].bytesused); > + temp_vb->b->vb2_buf.planes[0].bytesused); > spin_unlock_irqrestore(>irqlock, flags); > dev->curr_ctx = ctx->num; > s5p_mfc_init_decode_v6(ctx); > -- > 1.9.1 Best wishes, -- Kamil Debski Samsung R Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2 2/2] s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue
Hi Andrzej, > From: Andrzej Hajda [mailto:a.ha...@samsung.com] > Sent: Friday, October 02, 2015 2:10 PM > > MFC driver never delivered EOS event to apps feeding constantly its capture > buffer with fresh buffers. The patch fixes it by marking last buffers returned > by MFC with MFC_BUF_FLAG_EOS flag and firing EOS event on de-queuing > such buffers. Checkpatch complains that lines in the description are too long. WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line) #23: Best wishes, -- Kamil Debski Samsung R Institute Poland > > Signed-off-by: Andrzej Hajda <a.ha...@samsung.com> > --- > Hi, > > This version is rebased on latest media_tree branch. > > Regards > Andrzej > --- > drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + > drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 21 +--- > - > 2 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index 05a31ee..3ffe2ec 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -196,6 +196,7 @@ static void > s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx) > vb2_set_plane_payload(_buf->b->vb2_buf, 0, 0); > vb2_set_plane_payload(_buf->b->vb2_buf, 1, 0); > list_del(_buf->list); > + dst_buf->flags |= MFC_BUF_FLAG_EOS; > ctx->dst_queue_cnt--; > dst_buf->b->sequence = (ctx->sequence++); > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > index 1734775..8d3d40c 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c > @@ -645,17 +645,22 @@ static int vidioc_dqbuf(struct file *file, void *priv, > struct v4l2_buffer *buf) > mfc_err("Call on DQBUF after unrecoverable error\n"); > return -EIO; > } > - if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > - ret = vb2_dqbuf(>vq_src, buf, file->f_flags & > O_NONBLOCK); > - else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > + > + switch (buf->type) { > + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: > + return vb2_dqbuf(>vq_src, buf, file->f_flags & > O_NONBLOCK); > + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: > ret = vb2_dqbuf(>vq_dst, buf, file->f_flags & > O_NONBLOCK); > - if (ret == 0 && ctx->state == MFCINST_FINISHED && > - list_empty(>vq_dst.done_list)) > + if (ret) > + return ret; > + > + if (ctx->state == MFCINST_FINISHED && > + (ctx->dst_bufs[buf->index].flags & MFC_BUF_FLAG_EOS)) > v4l2_event_queue_fh(>fh, ); > - } else { > - ret = -EINVAL; > + return 0; > + default: > + return -EINVAL; > } > - return ret; > } > > /* Export DMA buffer */ > -- > 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] s5p-mfc: fix state check from encoder queue_setup
Hi, From: Andrzej Hajda [mailto:a.ha...@samsung.com] Sent: Tuesday, August 18, 2015 3:32 PM On 05/13/2015 09:25 AM, Seung-Woo Kim wrote: MFCINST_GOT_INST state is set to encoder context with set_format only for catpure buffer. In queue_setup of encoder called during reqbufs, it is checked MFCINST_GOT_INST state for both capture and output buffer. So this patch fixes to encoder to check MFCINST_GOT_INST state only for capture buffer from queue_setup. Signed-off-by: Seung-Woo Kim sw0312@samsung.com Looks OK. Reviewed-by: Andrzej Hajda a.ha...@samsung.com Acked-by: Kamil Debski k.deb...@samsung.com Regards Andrzej Best wishes, Kamil Debski --- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index e65993f..2e57e9f 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -1819,11 +1819,12 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, struct s5p_mfc_ctx *ctx = fh_to_ctx(vq-drv_priv); struct s5p_mfc_dev *dev = ctx-dev; - if (ctx-state != MFCINST_GOT_INST) { - mfc_err(inavlid state: %d\n, ctx-state); - return -EINVAL; - } if (vq-type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + if (ctx-state != MFCINST_GOT_INST) { + mfc_err(inavlid state: %d\n, ctx-state); + return -EINVAL; + } + if (ctx-dst_fmt) *plane_count = ctx-dst_fmt-num_planes; else -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv7 14/15] cec: s5p-cec: Add s5p-cec driver
Hi, On 21 July 2015 at 15:03, Marek Szyprowski m.szyprow...@samsung.com wrote: Hello, On 2015-07-16 15:09, Hans Verkuil wrote: Marek, Kamil, On 06/29/15 12:14, Hans Verkuil wrote: From: Kamil Debski ka...@wypas.org Add CEC interface driver present in the Samsung Exynos range of SoCs. The following files were based on work by SangPil Moon: - exynos_hdmi_cec.h - exynos_hdmi_cecctl.c Signed-off-by: Kamil Debski ka...@wypas.org Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- snip diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c new file mode 100644 index 000..0f16d00 --- /dev/null +++ b/drivers/media/platform/s5p-cec/s5p_cec.c @@ -0,0 +1,283 @@ +/* drivers/media/platform/s5p-cec/s5p_cec.c + * + * Samsung S5P CEC driver + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * 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 driver is based on the cec interface driver for exynos soc by + * SangPil Moon. + */ + +#include linux/clk.h +#include linux/interrupt.h +#include linux/kernel.h +#include linux/mfd/syscon.h +#include linux/module.h +#include linux/of.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/timer.h +#include linux/version.h +#include linux/workqueue.h +#include media/cec.h + +#include exynos_hdmi_cec.h +#include regs-cec.h +#include s5p_cec.h + +#define CEC_NAME s5p-cec + +static int debug; +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, debug level (0-2)); + +static int s5p_cec_enable(struct cec_adapter *adap, bool enable) +{ + struct s5p_cec_dev *cec = container_of(adap, struct s5p_cec_dev, adap); + int ret; + + if (enable) { + ret = pm_runtime_get_sync(cec-dev); + + adap-phys_addr = 0x100b; This is a bogus physical address. The actual physical address has to be derived from the EDID that is read by the HDMI transmitter. I think in the case of this driver it will have to be userspace that assigns the physical address after reading the EDID from drm/kms? How did you test this, Kamil? If I remember correctly, physical address has been derived from EDID in the userspace (it is available in /sys/class/drm/*) and passed to s5p-cec driver by appropriate ioctl. I don't know what is the reason for the above 'adap-phys_addr = 0x100b' assignment. At some point there was an idea to read the address from the EDID in kernel. This static address was a hack until the code that reads the EDID is written. As you say, it is much better to leave the address to be set by the userspace. So this assignment serves no purpose anymore. Best regards -- Marek Szyprowski, PhD Samsung RD Institute Poland Best wishes, Kamil -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v6 00/11] HDMI CEC framework
Hi, Sorry, I missed the subject for this cover-letter. Added it in this reply. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Kamil Debski [mailto:k.deb...@samsung.com] Sent: Monday, May 04, 2015 7:33 PM To: dri-de...@lists.freedesktop.org; linux-me...@vger.kernel.org Cc: m.szyprow...@samsung.com; k.deb...@samsung.com; mche...@osg.samsung.com; hverk...@xs4all.nl; kyungmin.p...@samsung.com; tho...@tommie-lie.de; s...@mess.org; dmitry.torok...@gmail.com; linux- in...@vger.kernel.org; linux-samsung-soc@vger.kernel.org; l...@opdenkamp.eu Subject: [PATCH v6 00/11] Hi, The sixth version of this patchset addresses recent comments on the mailing list. Please see the changelog below for details. Best wishes, Kamil Debski Changes since v5 - drop struct cec_timeval in favour of a __u64 that keeps the timestamp in ns - remove userspace documentation from Documentation/cec.txt as userspace API is described in the DocBook - add missing documentation for the passthrough mode to the DocBook - add information about the number of events that can be queued - fix misspelling of reply - fix behaviour of posting an event in cec_received_msg, such that the behaviour is consistent with the documentation Changes since v4 - add sequence numbering to transmitted messages - add sequence number handling to event hanlding - add passthrough mode - change reserved field sizes - fixed CEC version defines and addec CEC 2.0 commands - add DocBook documentation Changes since v3 - remove the promiscuous mode - rewrite the devicetree patches - fixes, expansion and partial rewrite of the documentation - reorder of API structures and addition of reserved fields - use own struct to report time (32/64 bit safe) - fix of handling events - add cec.h to include/uapi/linux/Kbuild - fixes in the adv76xx driver (add missing methods, change adv7604 to adv76xx) - cleanup of debug messages in s5p-cec driver - remove non necessary claiming of a gpio in the s5p-cec driver - cleanup headers of the s5p-cec driver Changes since v2 ===- - added promiscuous mode - added new key codes to the input framework - add vendor ID reporting - add the possibility to clear assigned logical addresses - cleanup of the rc cec map Changes since v1 - documentation edited and moved to the Documentation folder - added key up/down message handling - add missing CEC commands to the cec.h file Background == The work on a common CEC framework was started over three years ago by Hans Verkuil. Unfortunately the work has stalled. As I have received the task of creating a driver for the CEC interface module present on the Exynos range of SoCs, I got in touch with Hans. He replied that the work stalled due to his lack of time. Original RFC by Hans Verkuil/Martin Bugge = https://www.mail-archive.com/linux-media@vger.kernel.org/msg28735.html Hans Verkuil (5): cec: add HDMI CEC framework DocBook/media: add CEC documentation v4l2-subdev: add HDMI CEC ops cec: adv7604: add cec support. cec: adv7511: add cec support. Kamil Debski (6): dts: exynos4*: add HDMI CEC pin definition to pinctrl dts: exynos4: add node for the HDMI CEC device dts: exynos4412-odroid*: enable the HDMI CEC device HID: add HDMI CEC specific keycodes rc: Add HDMI CEC protoctol handling cec: s5p-cec: Add s5p-cec driver Documentation/DocBook/media/Makefile |4 +- Documentation/DocBook/media/v4l/biblio.xml | 10 + Documentation/DocBook/media/v4l/cec-api.xml| 74 ++ Documentation/DocBook/media/v4l/cec-func-close.xml | 59 + Documentation/DocBook/media/v4l/cec-func-ioctl.xml | 73 ++ Documentation/DocBook/media/v4l/cec-func-open.xml | 94 ++ Documentation/DocBook/media/v4l/cec-func-poll.xml | 89 ++ .../DocBook/media/v4l/cec-ioc-g-adap-log-addrs.xml | 275 + .../DocBook/media/v4l/cec-ioc-g-adap-phys-addr.xml | 78 ++ .../DocBook/media/v4l/cec-ioc-g-adap-state.xml | 87 ++ Documentation/DocBook/media/v4l/cec-ioc-g-caps.xml | 173 +++ .../DocBook/media/v4l/cec-ioc-g-event.xml | 125 ++ .../DocBook/media/v4l/cec-ioc-g-passthrough.xml| 88 ++ .../DocBook/media/v4l/cec-ioc-g-vendor-id.xml | 70 ++ .../DocBook/media/v4l/cec-ioc-receive.xml | 185 +++ Documentation/DocBook/media_api.tmpl |6 +- Documentation/cec.txt | 165 +++ .../devicetree/bindings/media/s5p-cec.txt | 33 + arch/arm/boot/dts/exynos4.dtsi | 12 + arch/arm/boot/dts/exynos4210-pinctrl.dtsi |7 + arch/arm/boot/dts/exynos4412-odroid-common.dtsi|4 + arch/arm/boot/dts/exynos4x12-pinctrl.dtsi |7 + drivers/media/Kconfig
[PATCH v5 06/11] cec: add HDMI CEC framework
From: Hans Verkuil hansv...@cisco.com The added HDMI CEC framework provides a generic kernel interface for HDMI CEC devices. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: Merged CEC Updates commit by Hans Verkuil] [k.deb...@samsung.com: Merged Update author commit by Hans Verkuil] [k.deb...@samsung.com: change kthread handling when setting logical address] [k.deb...@samsung.com: code cleanup and fixes] [k.deb...@samsung.com: add missing CEC commands to match spec] [k.deb...@samsung.com: add RC framework support] [k.deb...@samsung.com: move and edit documentation] [k.deb...@samsung.com: add vendor id reporting] [k.deb...@samsung.com: add possibility to clear assigned logical addresses] [k.deb...@samsung.com: documentation fixes, clenaup and expansion] [k.deb...@samsung.com: reorder of API structs and add reserved fields] [k.deb...@samsung.com: fix handling of events and fix 32/64bit timespec problem] [k.deb...@samsung.com: add cec.h to include/uapi/linux/Kbuild] [k.deb...@samsung.com: add sequence number handling] [k.deb...@samsung.com: add passthrough mode] [k.deb...@samsung.com: fix CEC defines, add missing CEC 2.0 commands] [k.deb...@samsung.com: add DocBook documentation by Hans Verkuil, with minor additions] Signed-off-by: Kamil Debski k.deb...@samsung.com --- Documentation/cec.txt | 396 +++ drivers/media/Kconfig |6 + drivers/media/Makefile|2 + drivers/media/cec.c | 1200 + include/media/cec.h | 142 ++ include/uapi/linux/Kbuild |1 + include/uapi/linux/cec.h | 337 + 7 files changed, 2084 insertions(+) create mode 100644 Documentation/cec.txt create mode 100644 drivers/media/cec.c create mode 100644 include/media/cec.h create mode 100644 include/uapi/linux/cec.h diff --git a/Documentation/cec.txt b/Documentation/cec.txt new file mode 100644 index 000..2b6c08a --- /dev/null +++ b/Documentation/cec.txt @@ -0,0 +1,396 @@ +CEC Kernel Support +== + +The CEC framework provides a unified kernel interface for use with HDMI CEC +hardware. It is designed to handle a multiple variants of hardware. Adding to +the flexibility of the framework it enables to set which parts of the CEC +protocol processing is handled by the hardware, by the driver and by the +userspace application. + + +The CEC Protocol + + +The CEC protocol enables consumer electronic devices to communicate with each +other through the HDMI connection. The protocol uses logical addresses in the +communication. The logical address is strictly connected with the functionality +provided by the device. The TV acting as the communication hub is always +assigned address 0. The physical address is determined by the physical +connection between devices. + +The protocol enables control of compatible devices with a single remote. +Synchronous power on/standby, instant playback with changing the content source +on the TV. + +The Kernel Interface + + +CEC Adapter +--- + +#define CEC_LOG_ADDR_INVALID 0xff + +/* The maximum number of logical addresses one device can be assigned to. + * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The + * Analog Devices CEC hardware supports 3. So let's go wild and go for 4. */ +#define CEC_MAX_LOG_ADDRS 4 + +/* The Primary Device Type */ +#define CEC_PRIM_DEVTYPE_TV0 +#define CEC_PRIM_DEVTYPE_RECORD1 +#define CEC_PRIM_DEVTYPE_TUNER 3 +#define CEC_PRIM_DEVTYPE_PLAYBACK 4 +#define CEC_PRIM_DEVTYPE_AUDIOSYSTEM 5 +#define CEC_PRIM_DEVTYPE_SWITCH6 +#define CEC_PRIM_DEVTYPE_VIDEOPROC 7 + +/* The All Device Types flags (CEC 2.0) */ +#define CEC_FL_ALL_DEVTYPE_TV (1 7) +#define CEC_FL_ALL_DEVTYPE_RECORD (1 6) +#define CEC_FL_ALL_DEVTYPE_TUNER (1 5) +#define CEC_FL_ALL_DEVTYPE_PLAYBACK(1 4) +#define CEC_FL_ALL_DEVTYPE_AUDIOSYSTEM (1 3) +#define CEC_FL_ALL_DEVTYPE_SWITCH (1 2) +/* And if you wondering what happened to VIDEOPROC devices: those should + * be mapped to a SWITCH. */ + +/* The logical address types that the CEC device wants to claim */ +#define CEC_LOG_ADDR_TYPE_TV 0 +#define CEC_LOG_ADDR_TYPE_RECORD 1 +#define CEC_LOG_ADDR_TYPE_TUNER2 +#define CEC_LOG_ADDR_TYPE_PLAYBACK 3 +#define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM 4 +#define CEC_LOG_ADDR_TYPE_SPECIFIC 5 +#define CEC_LOG_ADDR_TYPE_UNREGISTERED 6 +/* Switches should use UNREGISTERED. + * Video processors should use SPECIFIC. */ + +/* The CEC version */ +#define CEC_VERSION_1_4B 5 +#define CEC_VERSION_2_06 + +struct cec_adapter { + /* internal fields removed */ + + u16 phys_addr; + u32 capabilities; + u8 version; + u8 num_log_addrs; + u8 prim_device[CEC_MAX_LOG_ADDRS]; + u8 log_addr_type[CEC_MAX_LOG_ADDRS]; + u8 log_addr
[PATCH v5 11/11] DocBook/media: add CEC documentation
From: Hans Verkuil hverk...@xs4all.nl Add DocBook documentation for the CEC API. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: add documentation for passthrough mode] [k.deb...@samsung.com: minor fixes and change of reserved field sizes] Signed-off-by: Kamil Debski k.deb...@samsung.com --- Documentation/DocBook/media/Makefile |4 +- Documentation/DocBook/media/v4l/biblio.xml | 10 + Documentation/DocBook/media/v4l/cec-api.xml| 74 ++ Documentation/DocBook/media/v4l/cec-func-close.xml | 59 + Documentation/DocBook/media/v4l/cec-func-ioctl.xml | 73 ++ Documentation/DocBook/media/v4l/cec-func-open.xml | 94 +++ Documentation/DocBook/media/v4l/cec-func-poll.xml | 89 +++ .../DocBook/media/v4l/cec-ioc-g-adap-log-addrs.xml | 275 .../DocBook/media/v4l/cec-ioc-g-adap-phys-addr.xml | 78 ++ .../DocBook/media/v4l/cec-ioc-g-adap-state.xml | 87 +++ Documentation/DocBook/media/v4l/cec-ioc-g-caps.xml | 167 .../DocBook/media/v4l/cec-ioc-g-event.xml | 142 ++ .../DocBook/media/v4l/cec-ioc-g-vendor-id.xml | 70 + .../DocBook/media/v4l/cec-ioc-receive.xml | 185 + Documentation/DocBook/media_api.tmpl |6 +- 15 files changed, 1410 insertions(+), 3 deletions(-) create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-adap-log-addrs.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-adap-phys-addr.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-adap-state.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-caps.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-event.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-vendor-id.xml create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile index 8bf7c61..9650332 100644 --- a/Documentation/DocBook/media/Makefile +++ b/Documentation/DocBook/media/Makefile @@ -64,6 +64,7 @@ IOCTLS = \ $(shell perl -ne 'print $$1 if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/net.h) \ $(shell perl -ne 'print $$1 if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/video.h) \ $(shell perl -ne 'print $$1 if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/media.h) \ + $(shell perl -ne 'print $$1 if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/cec.h) \ $(shell perl -ne 'print $$1 if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \ VIDIOC_SUBDEV_G_FRAME_INTERVAL \ VIDIOC_SUBDEV_S_FRAME_INTERVAL \ @@ -98,6 +99,7 @@ STRUCTS = \ $(shell perl -ne 'print $$1 if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/net.h) \ $(shell perl -ne 'print $$1 if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/video.h) \ $(shell perl -ne 'print $$1 if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \ + $(shell perl -ne 'print $$1 if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/cec.h) \ $(shell perl -ne 'print $$1 if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \ $(shell perl -ne 'print $$1 if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h) @@ -300,7 +302,7 @@ $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml @( \ for ident in $(IOCTLS) ; do \ entity=`echo $$ident | tr _ -` ; \ - id=`grep refname$$ident $(MEDIA_OBJ_DIR)/vidioc-*.xml $(MEDIA_OBJ_DIR)/media-ioc-*.xml | sed -r s,^.*/(.*).xml.*,\1,` ; \ + id=`grep refname$$ident $(MEDIA_OBJ_DIR)/vidioc-*.xml $(MEDIA_OBJ_DIR)/media-ioc-*.xml $(MEDIA_OBJ_DIR)/cec-ioc-*.xml | sed -r s,^.*/(.*).xml.*,\1,` ; \ echo !ENTITY $$entity \link \ linkend='$$id'constant$$ident/constant/link\ \ $@ ;\ diff --git a/Documentation/DocBook/media/v4l/biblio.xml b/Documentation/DocBook/media/v4l/biblio.xml index fdee6b3..bed940b 100644 --- a/Documentation/DocBook/media/v4l/biblio.xml +++ b/Documentation/DocBook/media/v4l/biblio.xml @@ -324,6 +324,16 @@ in the frequency range from 87,5 to 108,0 MHz/title subtitleSpecification Version 1.4a
[PATCH] libgencec: Add userspace library for the generic CEC kernel interface
This is the first version of the libGenCEC library. It was designed to act as an interface between the generic CEC kernel API and userspace applications. It provides a simple interface for applications and an example application that can be used to test the CEC functionality. signed-off-by: Kamil Debski k.deb...@samsung.com --- AUTHORS |1 + INSTALL |9 + LICENSE | 202 Makefile.am |4 + README | 22 ++ configure.ac | 24 ++ doc/index.html | 345 +++ examples/Makefile.am |4 + examples/cectest.c | 631 ++ include/gencec.h | 255 src/Makefile.am |4 + src/gencec.c | 445 +++ 12 files changed, 1946 insertions(+) create mode 100644 AUTHORS create mode 100644 INSTALL create mode 100644 LICENSE create mode 100644 Makefile.am create mode 100644 README create mode 100644 configure.ac create mode 100644 doc/index.html create mode 100644 examples/Makefile.am create mode 100644 examples/cectest.c create mode 100644 include/gencec.h create mode 100644 m4/.gitkeep create mode 100644 src/Makefile.am create mode 100644 src/gencec.c diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000..e4b7117 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Kamil Debski k.deb...@samsung.com diff --git a/INSTALL b/INSTALL new file mode 100644 index 000..aac6101 --- /dev/null +++ b/INSTALL @@ -0,0 +1,9 @@ +To install libgencec run following commands: + +autoreconf -i +./configure +make +make install + +A cross compilation example for ARM: +CFLAGS=-Ikernel headers ./configure --host=arm-linux-gnueabi --prefix=installation prefix diff --git a/LICENSE b/LICENSE new file mode 100644 index 000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 +http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + License shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + Licensor shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + Legal Entity shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + control means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + You (or Your) shall mean an individual or Legal Entity + exercising permissions granted by this License. + + Source form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + Object form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + Work shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + Derivative Works shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + Contribution shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, submitted + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue
RE: [PATCH v4 06/10] cec: add HDMI CEC framework
Hi Lars, Thank you for your comments. From: linux-media-ow...@vger.kernel.org [mailto:linux-media- ow...@vger.kernel.org] On Behalf Of Lars Op den Kamp Sent: Friday, April 24, 2015 12:04 PM Hi Kamil, Hans, I'm the main developer of libCEC (https://github.com/Pulse-Eight/libcec). Sorry for the late time to jump in here, but I wasn't signed up to this mailing list and someone pointed me to this discussion. Unfortunately this approach will not work with half the TVs that are out there. I'll explain why: * because of how some (common) brands implemented CEC in their TVs, this implementation will not work, as the TV will just reject it. In libCEC, we've created work arounds for brands like this. Without these work arounds, your in-kernel implementation will be very vendor specific. e.g. this implementation will work for Samsung's TVs, but not for the TVs made by another big TV brand. All commands, including CEC_OP_ABORT, should be passed to userspace to make it work with all brands. * it should be made possible to not have the kernel send any CEC message, try to process any received CEC message, or ack to any logical address at all, to allow libraries like libCEC to fully handle all CEC traffic. Some brands only enable routing of some CEC keys when a specific device type is used. libCEC will allocate a logical address of the correct type for the brand that's used. If another address is first allocated by the kernel, and the TV communicates with it to find out it's name and things like that, and libCEC allocates another address a bit later when initialised, then you'll end up with multiple entries in the device list on the TV, and only one of them will work. Adding a special mode in the CEC framework that disables parsing and processing seems like a good idea for me. This way libCEC could be completely in charge of how the communication is handled. I discussed this with Hans and he is for this solution. This way there would be two modes: - One with handling of CEC messages enabled in the kernel, in idea behind this is to have processing adhere to the CEC spec as closely as possible. It should work with equipment that also follows the spec and has little vendor specific quirks. - Second, the passthrough mode, in which the handling of CEC messages would be left to userspace application. Kernel would not be sending or receiving messages, unless specifically told to do so. Below you mentioned that allocating logical addresses and sending ACKs could be done in kernel. The way I see it is following: If allocation of a logical address is made then ACKs will be handled by the framework. If no allocation is made then the userspace can still send and receive messages. However no filtering is done based on the logical address - all received messages are sent to the userspace. * CEC is *very* vendor specific. The main reason is, in my opinion, the use of the word should instead of shall in the spec. It's addressed in the new version, but it'll take years before all the non 2.x devices are gone. What works for vendor A will simply not work for vendor B. libCEC aims to address this, in a library that can be used on all major platforms and by all major programming languages. You could duplicate the work done there in the kernel to make make the implementation work with all brands, but I think that this does simply not belong in the kernel when it can be handled in userspace perfectly. CEC being very vendor specific is a huge problem. I agree with you that there is no need to duplicate the effort to mitigate all the vendor quirks. Especially that a working implementation (libCEC) is already done. So I suggest that you limit the in-kernel implementation to handling raw traffic only, to have it do this (and nothing more): * allocate one or more logical addresses, and ack CEC traffic sent to those logical addresses * receive CEC traffic and forward it to userspace (traffic sent to all addresses is preferred, not just traffic sent to the logical address used by the device running this code) * transmit CEC traffic initiated by userspace As mentioned above, I propose a passthorugh mode in which handling of CEC messages by the kernel CEC framework will be very limited. I think that the three functions listed above should be enough. Any comments on this solution? thanks, Lars Op den Kamp Best wishes, -- Kamil Debski Samsung RD Institute Poland On 23-04-15 15:03, Kamil Debski wrote: From: Hans Verkuil hansv...@cisco.com The added HDMI CEC framework provides a generic kernel interface for HDMI CEC devices. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: Merged CEC Updates commit by Hans Verkuil] [k.deb...@samsung.com: Merged Update author commit by Hans Verkuil] [k.deb...@samsung.com: change kthread handling when setting logical address] [k.deb...@samsung.com: code cleanup and fixes
RE: [PATCH v4 06/10] cec: add HDMI CEC framework
Hi Hans, Thank you so much for all today's comments. I will consider them when preparing the next version. From: linux-media-ow...@vger.kernel.org [mailto:linux-media- ow...@vger.kernel.org] On Behalf Of Hans Verkuil Sent: Monday, April 27, 2015 1:27 PM On 04/27/2015 12:25 PM, Hans Verkuil wrote: On 04/23/2015 03:03 PM, Kamil Debski wrote: From: Hans Verkuil hansv...@cisco.com The added HDMI CEC framework provides a generic kernel interface for HDMI CEC devices. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: Merged CEC Updates commit by Hans Verkuil] [k.deb...@samsung.com: Merged Update author commit by Hans Verkuil] [k.deb...@samsung.com: change kthread handling when setting logical address] [k.deb...@samsung.com: code cleanup and fixes] [k.deb...@samsung.com: add missing CEC commands to match spec] [k.deb...@samsung.com: add RC framework support] [k.deb...@samsung.com: move and edit documentation] [k.deb...@samsung.com: add vendor id reporting] [k.deb...@samsung.com: add possibility to clear assigned logical addresses] [k.deb...@samsung.com: documentation fixes, clenaup and expansion] [k.deb...@samsung.com: reorder of API structs and add reserved fields] [k.deb...@samsung.com: fix handling of events and fix 32/64bit timespec problem] [k.deb...@samsung.com: add cec.h to include/uapi/linux/Kbuild] Signed-off-by: Kamil Debski k.deb...@samsung.com --- Documentation/cec.txt | 396 drivers/media/Kconfig |6 + drivers/media/Makefile|2 + drivers/media/cec.c | 1161 + include/media/cec.h | 140 ++ include/uapi/linux/Kbuild |1 + include/uapi/linux/cec.h | 303 7 files changed, 2009 insertions(+) create mode 100644 Documentation/cec.txt create mode 100644 drivers/media/cec.c create mode 100644 include/media/cec.h create mode 100644 include/uapi/linux/cec.h + case CEC_S_ADAP_LOG_ADDRS: { + struct cec_log_addrs log_addrs; + + if (!(adap-capabilities CEC_CAP_LOG_ADDRS)) + return -ENOTTY; + if (copy_from_user(log_addrs, parg, sizeof(log_addrs))) + return -EFAULT; + err = cec_claim_log_addrs(adap, log_addrs, true); Currently CEC_S_ADAP_LOG_ADDRS is always blocking, but since we have CEC_EVENT_READY I think it makes sense to just return in non-blocking mode and have cec_claim_log_addrs generate CEC_EVENT_READY when done. Userspace can then call G_ADAP_LOG_ADDRS to discover the result. What do you think? I am looking into this now. If I see this correctly this involves: - adding cec_post_event(cla_int-adap, CEC_EVENT_READY); to cec_config_thread_func - adding O_NONBLOCK check in CEC_S_ADAP_LOG_ADDRS Right? On a related topic: non-blocking behavior for CEC_RECEIVE is well defined, but for CEC_TRA NSMIT it isn't. If reply == 0, then we need a way to inform userspace that the transmit finished (with a possible non-zero status code). An event would be suitable for that, but we would need a way to associate a transmit message with the event. One possibility might be to have the CEC framework assign a sequence number to a transmit message which is returned by CEC_TRANSMIT and used in the event. If reply != 0, then I think the received message should be queued up in the receive queue, but with a non-zero reply field and with the sequence number of the transmit message it is a reply of. A sequence number is a good solution, I believe. To recap: - a sequence number should be set by the framework and returned in the CEC_TRANSMIT ioctl - a new event should be added CEC_EVENT_TX_DONE and it should be posted on each transmission finish - event struct has to include a sequence field as well Is this ok? Regards, Hans Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 00/10] HDMI CEC framework
Hi, This is the fourth version of the HDMI CEC framework. I would like to thank for all the comments and suggestions to the previous versions of this patch. I believe that the code has matured enough to be tagged as PATCH and not RFC as in previous version. This patchset is base on the linux-next tree. I believe that there will be some comments to it and there will be some things to fix, hence I am sending this version now. The next version with appropriate fixes will be based on the next RC (which I guess will be released soon). The promiscuous mode included in the previous version caused some discussion and I decided to drop it. In my opinion it can be useful for debugging, but on the other hand I believe it can be easily added at a later time, if appropriate. Best wishes, Kamil Debski Changes since v3 - remove the promiscuous mode - rewrite the devicetree patches - fixes, expansion and partial rewrite of the documentation - reorder of API structures and addition of reserved fields - use own struct to report time (32/64 bit safe) - fix of handling events - add cec.h to include/uapi/linux/Kbuild - fixes in the adv76xx driver (add missing methods, change adv7604 to adv76xx) - cleanup of debug messages in s5p-cec driver - remove non necessary claiming of a gpio in the s5p-cec driver - cleanup headers of the s5p-cec driver Changes since v2 ===- - added promiscuous mode - added new key codes to the input framework - add vendor ID reporting - add the possibility to clear assigned logical addresses - cleanup of the rc cec map Changes since v1 - documentation edited and moved to the Documentation folder - added key up/down message handling - add missing CEC commands to the cec.h file Original cover letter = Hi, The work on a common CEC framework was started over three years ago by Hans Verkuil. Unfortunately the work has stalled. As I have received the task of creating a driver for the CEC interface module present on the Exynos range of SoCs, I got in touch with Hans. He replied that the work stalled due to his lack of time. The driver was done in the most part and there were only minor fixes that needed to be implemented. I would like to bring back the discussion on a common CEC interface framework. There are a few things that were still left as TODO, I think they might need some discussion - for instance the way how the remote controls should be handled. Best wishes, Kamil Debski Original RFC by Hans Verkuil/Martin Bugge = https://www.mail-archive.com/linux-media@vger.kernel.org/msg28735.html Hans Verkuil (4): cec: add HDMI CEC framework v4l2-subdev: add HDMI CEC ops cec: adv7604: add cec support. cec: adv7511: add cec support. Kamil Debski (6): dts: exynos4*: add HDMI CEC pin definition to pinctrl dts: exynos4: add node for the HDMI CEC device dts: exynos4412-odroid*: enable the HDMI CEC device HID: add HDMI CEC specific keycodes rc: Add HDMI CEC protoctol handling cec: s5p-cec: Add s5p-cec driver Documentation/cec.txt | 396 +++ .../devicetree/bindings/media/s5p-cec.txt | 33 + arch/arm/boot/dts/exynos4.dtsi | 12 + arch/arm/boot/dts/exynos4210-pinctrl.dtsi |7 + arch/arm/boot/dts/exynos4412-odroid-common.dtsi|4 + arch/arm/boot/dts/exynos4x12-pinctrl.dtsi |7 + drivers/media/Kconfig |6 + drivers/media/Makefile |2 + drivers/media/cec.c| 1161 drivers/media/i2c/adv7511.c| 347 +- drivers/media/i2c/adv7604.c| 207 +++- drivers/media/platform/Kconfig | 10 + drivers/media/platform/Makefile|1 + drivers/media/platform/s5p-cec/Makefile|4 + drivers/media/platform/s5p-cec/exynos_hdmi_cec.h | 37 + .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c | 208 drivers/media/platform/s5p-cec/regs-cec.h | 96 ++ drivers/media/platform/s5p-cec/s5p_cec.c | 283 + drivers/media/platform/s5p-cec/s5p_cec.h | 76 ++ drivers/media/rc/keymaps/Makefile |1 + drivers/media/rc/keymaps/rc-cec.c | 144 +++ drivers/media/rc/rc-main.c |1 + include/media/adv7511.h|6 +- include/media/cec.h| 140 +++ include/media/rc-core.h|1 + include/media/rc-map.h |5 +- include/media/v4l2-subdev.h|8 + include/uapi/linux/Kbuild |1 + include/uapi/linux/cec.h | 303 + include/uapi/linux/input.h | 12 + 30 files changed, 3507
[PATCH v4 03/10] dts: exynos4412-odroid*: enable the HDMI CEC device
Add a dts node entry and enable the HDMI CEC device present in the Exynos4 family of SoCs. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos4412-odroid-common.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi index 8de12af..e50862d 100644 --- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi +++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi @@ -469,6 +469,10 @@ status = okay; }; + cec@100B { + status = okay; + }; + hdmi_ddc: i2c@1388 { status = okay; pinctrl-names = default; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 02/10] dts: exynos4: add node for the HDMI CEC device
This patch adds HDMI CEC node specific to the Exynos4210/4x12 SoC series. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos4.dtsi | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index e20cdc2..8776db9 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -704,6 +704,18 @@ status = disabled; }; + hdmicec: cec@100B { + compatible = samsung,s5p-cec; + reg = 0x100B 0x200; + interrupts = 0 114 0; + clocks = clock CLK_HDMI_CEC; + clock-names = hdmicec; + samsung,syscon-phandle = pmu_system_controller; + pinctrl-names = default; + pinctrl-0 = hdmi_cec; + status = disabled; + }; + mixer: mixer@12C1 { compatible = samsung,exynos4210-mixer; interrupts = 0 91 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 01/10] dts: exynos4*: add HDMI CEC pin definition to pinctrl
Add pinctrl nodes for the HDMI CEC device to the Exynos4210 and Exynos4x12 SoCs. These are required by the HDMI CEC device. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos4210-pinctrl.dtsi |7 +++ arch/arm/boot/dts/exynos4x12-pinctrl.dtsi |7 +++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/exynos4210-pinctrl.dtsi b/arch/arm/boot/dts/exynos4210-pinctrl.dtsi index a7c2128..9331c62 100644 --- a/arch/arm/boot/dts/exynos4210-pinctrl.dtsi +++ b/arch/arm/boot/dts/exynos4210-pinctrl.dtsi @@ -820,6 +820,13 @@ samsung,pin-pud = 1; samsung,pin-drv = 0; }; + + hdmi_cec: hdmi-cec { + samsung,pins = gpx3-6; + samsung,pin-function = 3; + samsung,pin-pud = 0; + samsung,pin-drv = 0; + }; }; pinctrl@0386 { diff --git a/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi b/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi index c141931..875464e 100644 --- a/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi +++ b/arch/arm/boot/dts/exynos4x12-pinctrl.dtsi @@ -885,6 +885,13 @@ samsung,pin-pud = 0; samsung,pin-drv = 0; }; + + hdmi_cec: hdmi-cec { + samsung,pins = gpx3-6; + samsung,pin-function = 3; + samsung,pin-pud = 0; + samsung,pin-drv = 0; + }; }; pinctrl@0386 { -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 04/10] HID: add HDMI CEC specific keycodes
Add HDMI CEC specific keycodes to the keycodes definition. Signed-off-by: Kamil Debski k.deb...@samsung.com --- include/uapi/linux/input.h | 12 1 file changed, 12 insertions(+) diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index 731417c..7430a3f 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -752,6 +752,18 @@ struct input_keymap_entry { #define KEY_KBDINPUTASSIST_ACCEPT 0x264 #define KEY_KBDINPUTASSIST_CANCEL 0x265 +#define KEY_RIGHT_UP 0x266 +#define KEY_RIGHT_DOWN 0x267 +#define KEY_LEFT_UP0x268 +#define KEY_LEFT_DOWN 0x269 + +#define KEY_NEXT_FAVORITE 0x270 +#define KEY_STOP_RECORD0x271 +#define KEY_PAUSE_RECORD 0x272 +#define KEY_VOD0x273 +#define KEY_UNMUTE 0x274 +#define KEY_DVB0x275 + #define BTN_TRIGGER_HAPPY 0x2c0 #define BTN_TRIGGER_HAPPY1 0x2c0 #define BTN_TRIGGER_HAPPY2 0x2c1 -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 05/10] rc: Add HDMI CEC protoctol handling
Add handling of remote control events coming from the HDMI CEC bus. This patch includes a new keymap that maps values found in the CEC messages to the keys pressed and released. Also, a new protocol has been added to the core. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/media/rc/keymaps/Makefile |1 + drivers/media/rc/keymaps/rc-cec.c | 144 + drivers/media/rc/rc-main.c|1 + include/media/rc-core.h |1 + include/media/rc-map.h|5 +- 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 drivers/media/rc/keymaps/rc-cec.c diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile index abf6079..56f10d6 100644 --- a/drivers/media/rc/keymaps/Makefile +++ b/drivers/media/rc/keymaps/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-behold.o \ rc-behold-columbus.o \ rc-budget-ci-old.o \ + rc-cec.o \ rc-cinergy-1400.o \ rc-cinergy.o \ rc-delock-61959.o \ diff --git a/drivers/media/rc/keymaps/rc-cec.c b/drivers/media/rc/keymaps/rc-cec.c new file mode 100644 index 000..cc5b318 --- /dev/null +++ b/drivers/media/rc/keymaps/rc-cec.c @@ -0,0 +1,144 @@ +/* Keytable for the CEC remote control + * + * Copyright (c) 2015 by 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. + */ + +#include media/rc-map.h +#include linux/module.h + +/* CEC Spec High-Definition Multimedia Interface Specification can be obtained + * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf + * The list of control codes is listed in Table 27: User Control Codes p. 95 */ + +static struct rc_map_table cec[] = { + { 0x00, KEY_OK }, + { 0x01, KEY_UP }, + { 0x02, KEY_DOWN }, + { 0x03, KEY_LEFT }, + { 0x04, KEY_RIGHT }, + { 0x05, KEY_RIGHT_UP }, + { 0x06, KEY_RIGHT_DOWN }, + { 0x07, KEY_LEFT_UP }, + { 0x08, KEY_LEFT_DOWN }, + { 0x09, KEY_CONTEXT_MENU }, /* CEC Spec: Root Menu - see Note 2 */ + /* Note 2: This is the initial display that a device shows. It is +* device-dependent and can be, for example, a contents menu, setup +* menu, favorite menu or other menu. The actual menu displayed +* may also depend on the device’s current state. */ + { 0x0a, KEY_SETUP }, + { 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */ + { 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */ + { 0x0d, KEY_EXIT }, + /* 0x0e-0x1f: Reserved */ + /* 0x20-0x29: Keys 0 to 9 */ + { 0x20, KEY_NUMERIC_0 }, + { 0x21, KEY_NUMERIC_1 }, + { 0x22, KEY_NUMERIC_2 }, + { 0x23, KEY_NUMERIC_3 }, + { 0x24, KEY_NUMERIC_4 }, + { 0x25, KEY_NUMERIC_5 }, + { 0x26, KEY_NUMERIC_6 }, + { 0x27, KEY_NUMERIC_7 }, + { 0x28, KEY_NUMERIC_8 }, + { 0x29, KEY_NUMERIC_9 }, + { 0x2a, KEY_DOT }, + { 0x2b, KEY_ENTER }, + { 0x2c, KEY_CLEAR }, + /* 0x2d-0x2e: Reserved */ + { 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */ + { 0x30, KEY_CHANNELUP }, + { 0x31, KEY_CHANNELDOWN }, + { 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */ + { 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */ + { 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */ + { 0x35, KEY_INFO }, /* CEC Spec: Display Information */ + { 0x36, KEY_HELP }, + { 0x37, KEY_PAGEUP }, + { 0x38, KEY_PAGEDOWN }, + /* 0x39-0x3f: Reserved */ + { 0x40, KEY_POWER }, + { 0x41, KEY_VOLUMEUP }, + { 0x42, KEY_VOLUMEDOWN }, + { 0x43, KEY_MUTE }, + { 0x44, KEY_PLAY }, + { 0x45, KEY_STOP }, + { 0x46, KEY_PAUSE }, + { 0x47, KEY_RECORD }, + { 0x48, KEY_REWIND }, + { 0x49, KEY_FASTFORWARD }, + { 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */ + { 0x4b, KEY_FORWARD }, + { 0x4c, KEY_BACK }, + { 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */ + { 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */ + /* 0x4f: Reserved */ + { 0x50, KEY_ANGLE }, + { 0x51, KEY_TV2 }, + { 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */ + { 0x53, KEY_EPG }, + { 0x54, KEY_TIME }, /* CEC Spec: Timer */ + { 0x55, KEY_CONFIG }, + /* 0x56-0x5f: Reserved */ + { 0x60, KEY_PLAY }, /* CEC Spec: Play Function */ + { 0x6024, KEY_PLAY }, + { 0x6020, KEY_PAUSE }, + { 0x61, KEY_PLAYPAUSE }, /* CEC Spec: Pause-Play Function */ + { 0x62, KEY_RECORD }, /* Spec: Record Function */ + { 0x63, KEY_PAUSE
[PATCH v4 07/10] v4l2-subdev: add HDMI CEC ops
From: Hans Verkuil hansv...@cisco.com Add callbacks to the v4l2_subdev_video_ops. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil] Signed-off-by: Kamil Debski k.deb...@samsung.com --- include/media/v4l2-subdev.h |8 1 file changed, 8 insertions(+) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 2f0a345..9323e10 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -40,6 +40,9 @@ #define V4L2_SUBDEV_IR_TX_NOTIFY _IOW('v', 1, u32) #define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x0001 +#define V4L2_SUBDEV_CEC_TX_DONE_IOW('v', 2, u32) +#define V4L2_SUBDEV_CEC_RX_MSG _IOW('v', 3, struct cec_msg) + struct v4l2_device; struct v4l2_ctrl_handler; struct v4l2_event_subscription; @@ -48,6 +51,7 @@ struct v4l2_subdev; struct v4l2_subdev_fh; struct tuner_setup; struct v4l2_mbus_frame_desc; +struct cec_msg; /* decode_vbi_line */ struct v4l2_decode_vbi_line { @@ -352,6 +356,10 @@ struct v4l2_subdev_video_ops { const struct v4l2_mbus_config *cfg); int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf, unsigned int *size); + int (*cec_enable)(struct v4l2_subdev *sd, bool enable); + int (*cec_log_addr)(struct v4l2_subdev *sd, u8 logical_addr); + int (*cec_transmit)(struct v4l2_subdev *sd, struct cec_msg *msg); + void (*cec_transmit_timed_out)(struct v4l2_subdev *sd); }; /* -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 08/10] cec: adv7604: add cec support.
From: Hans Verkuil hansv...@cisco.com Add CEC support to the adv7604 driver. Signed-off-by: Hans Verkuil hansv...@cisco.com [k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil] [k.deb...@samsung.com: add missing methods cec/io_write_and_or] [k.deb...@samsung.com: change adv7604 to adv76xx in added functions] Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/media/i2c/adv7604.c | 207 ++- 1 file changed, 206 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 60ffcf0..4921276 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -38,6 +38,7 @@ #include linux/workqueue.h #include media/adv7604.h +#include media/cec.h #include media/v4l2-ctrls.h #include media/v4l2-device.h #include media/v4l2-dv-timings.h @@ -77,6 +78,8 @@ MODULE_LICENSE(GPL); #define ADV76XX_OP_SWAP_CB_CR (1 0) +#define ADV76XX_MAX_ADDRS (3) + enum adv76xx_type { ADV7604, ADV7611, @@ -159,6 +162,10 @@ struct adv76xx_state { u16 spa_port_a[2]; struct v4l2_fract aspect_ratio; u32 rgb_quantization_range; + u8 cec_addr[ADV76XX_MAX_ADDRS]; + u8 cec_valid_addrs; + bool cec_enabled_adap; + struct workqueue_struct *work_queues; struct delayed_work delayed_work_enable_hotplug; bool restart_stdi_once; @@ -424,7 +431,15 @@ static inline int io_write(struct v4l2_subdev *sd, u8 reg, u8 val) return adv_smbus_write_byte_data(state, ADV76XX_PAGE_IO, reg, val); } -static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) +static inline int io_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, + u8 val) +{ + return io_write(sd, reg, (io_read(sd, reg) mask) | val); +} + + +static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, + u8 val) { return io_write(sd, reg, (io_read(sd, reg) ~mask) | val); } @@ -457,6 +472,12 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 reg, u8 val) return adv_smbus_write_byte_data(state, ADV76XX_PAGE_CEC, reg, val); } +static inline int cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, + u8 val) +{ + return cec_write(sd, reg, (cec_read(sd, reg) mask) | val); +} + static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg) { struct adv76xx_state *state = to_state(sd); @@ -1865,6 +1886,183 @@ static int adv76xx_set_format(struct v4l2_subdev *sd, return 0; } +static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status) +{ + if ((cec_read(sd, 0x11) 0x01) == 0) { + v4l2_dbg(1, debug, sd, %s: tx raw: tx disabled\n, __func__); + return; + } + + if (tx_raw_status 0x02) { + v4l2_dbg(1, debug, sd, %s: tx raw: arbitration lost\n, +__func__); + v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE, + (void *)CEC_TX_STATUS_ARB_LOST); + return; + } + if (tx_raw_status 0x04) { + v4l2_dbg(1, debug, sd, %s: tx raw: retry failed\n, __func__); + v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE, + (void *)CEC_TX_STATUS_RETRY_TIMEOUT); + return; + } + if (tx_raw_status 0x01) { + v4l2_dbg(1, debug, sd, %s: tx raw: ready ok\n, __func__); + v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_TX_DONE, + (void *)CEC_TX_STATUS_OK); + return; + } +} + +static void adv76xx_cec_isr(struct v4l2_subdev *sd, bool *handled) +{ + struct cec_msg msg; + u8 cec_irq; + + /* cec controller */ + cec_irq = io_read(sd, 0x4d) 0x0f; + if (!cec_irq) + return; + + v4l2_dbg(1, debug, sd, %s: cec: irq 0x%x\n, __func__, cec_irq); + adv76xx_cec_tx_raw_status(sd, cec_irq); + if (cec_irq 0x08) { + msg.len = cec_read(sd, 0x25) 0x1f; + if (msg.len 16) + msg.len = 16; + + if (msg.len) { + u8 i; + + for (i = 0; i msg.len; i++) + msg.msg[i] = cec_read(sd, i + 0x15); + cec_write(sd, 0x26, 0x01); /* re-enable rx */ + v4l2_subdev_notify(sd, V4L2_SUBDEV_CEC_RX_MSG, msg); + } + } + + /* note: the bit order is swapped between 0x4d and 0x4e */ + cec_irq = ((cec_irq 0x08) 3) | ((cec_irq 0x04) 1) | + ((cec_irq 0x02) 1) | ((cec_irq 0x01) 3); + io_write(sd, 0x4e, cec_irq); + + if (handled) + *handled = true; +} + +static int
RE: [PATCHv2 1/2] ARM: dts: exynos5420: add nodes for jpeg codec
Hi Andrzej, From: linux-media-ow...@vger.kernel.org [mailto:linux-media- ow...@vger.kernel.org] On Behalf Of Andrzej Pietrasiewicz Sent: Friday, March 06, 2015 11:33 AM Thank you for your patch. Regardless how simple the patch is, there should be some description. In the v2 of the patch set please add a description. One sentence should be enough. Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com --- arch/arm/boot/dts/exynos5420.dtsi | 16 1 file changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi index 73c1851..f8f583c 100644 --- a/arch/arm/boot/dts/exynos5420.dtsi +++ b/arch/arm/boot/dts/exynos5420.dtsi @@ -775,6 +775,22 @@ iommus = sysmmu_gscl1; }; + jpeg_0: jpeg@11F5 { + compatible = samsung,exynos5420-jpeg; + reg = 0x11F5 0x1000; + interrupts = 0 89 0; + clock-names = jpeg; + clocks = clock CLK_JPEG; + }; + + jpeg_1: jpeg@11F6 { + compatible = samsung,exynos5420-jpeg; + reg = 0x11F6 0x1000; + interrupts = 0 168 0; + clock-names = jpeg; + clocks = clock CLK_JPEG2; + }; + pmu_system_controller: system-controller@1004 { compatible = samsung,exynos5420-pmu, syscon; reg = 0x1004 0x5000; -- 1.9.1 -- 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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-soc@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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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-ker...@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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm
Hi Zhaowei, Please provide a short and informative commit description. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Zhaowei Yuan [mailto:zhaowei.y...@samsung.com] Sent: Tuesday, August 05, 2014 9:13 AM To: linux-me...@vger.kernel.org; k.deb...@samsung.com; m.che...@samsung.com; kyungmin.p...@samsung.com; jtp.p...@samsung.com Cc: linux-samsung-soc@vger.kernel.org Subject: [PATCH] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm Signed-off-by: Zhaowei Yuan zhaowei.y...@samsung.com --- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |1 + 1 file changed, 1 insertion(+) mode change 100644 = 100755 drivers/media/platform/s5p- mfc/s5p_mfc_opr_v5.c diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c old mode 100644 new mode 100755 index 58ec7bb..dc00aea --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c @@ -228,6 +228,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx) ret = s5p_mfc_alloc_priv_buf(dev-mem_dev_l, ctx-shm); if (ret) { mfc_err(Failed to allocate shared memory buffer\n); + s5p_mfc_release_priv_buf(dev-mem_dev_l, ctx-ctx); return ret; } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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
[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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2 2/2] s5p-mfc: Adding MFC v7 and v8 firmwares
Hi Arun, Ben, From: arunkk.sams...@gmail.com [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Wednesday, June 04, 2014 7:32 AM Hi Ben, On Wed, Jun 4, 2014 at 4:56 AM, Ben Hutchings b...@decadent.org.uk wrote: On Tue, 2014-06-03 at 20:34 +0100, Ben Hutchings wrote: On Wed, 2014-05-21 at 18:11 +0530, Arun Kumar K wrote: Adding the following firmware files for MFC s5p-mfc-v7.fw: Used in exynos 5420 s5p-mfc-v8.fw: Used in exynos 5800 Signed-off-by: Arun Kumar K arun...@samsung.com --- Changes from v1 - None --- WHENCE|2 ++ s5p-mfc/s5p-mfc-v7.fw | Bin 0 - 382724 bytes s5p-mfc/s5p-mfc-v8.fw | Bin 0 - 360576 bytes 3 files changed, 2 insertions(+) create mode 100644 s5p-mfc/s5p-mfc-v7.fw create mode 100644 s5p-mfc/s5p-mfc-v8.fw [...] Applied, thanks. Just noticed a problem with all the s5p-mfc firmware: you are putting it in the s5p-mfc subdirectory, so distribution packages will install them in /lib/firmware/s5p-mfc. However, unless I'm mistaken your driver requests it with a bare filename (e.g. s5p-mfc-v7.fw) so it won't be found. Yes this issue is there. Kamil, are you ok with changing the fw load path to s5p-mfc/s5p-mfc*.fw in the driver? We have two options here: 1) Change the driver to request s5p-mfc/sp5-mfc-fw* 2) Move the files in the firmware repository I would opt for the second option. The driver was uploaded before the firmware. I see that there are many firmware files in the root folder of the repository Ben, what is your opinion? Which is preferred: creating subdirectories or storing firmware in the root folder? Best wishes, -- Kamil Debski Samsung RD Institute Poland Regards Arun Ben. -- Ben Hutchings Experience is what causes a person to make new mistakes instead of old ones. -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware
Hi Tomasz, Arun, From: Tomasz Figa [mailto:t.f...@samsung.com] Sent: Friday, May 16, 2014 12:22 PM Hi Kamil, Arun, On 16.05.2014 12:09, Kamil Debski wrote: Hi, Original Message- From: arunkk.sams...@gmail.com [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, May 16, 2014 12:00 PM Hi Kamil, On Fri, May 16, 2014 at 3:24 PM, Kamil Debski k.deb...@samsung.com wrote: Hi Arun, I asked you to put old and new v6 firmware in separate files. But wont that require a different filename other than s5p-mfc-v6.fw? Yes. But the driver still expects the same file name. Can I put the new filename as s5p-mfc-v6-v2.fw and mention in the README that the file has to be renamed to s5p-mfc-v6.fw to be used? I think this is the way to go, because the new driver (with the patch) will work with old firmware, while old driver (without the patch) will not work with the new firmware. You should also mention in the commit message that this new firmware will not work with the s5p-mfc driver without the patch you recently submitted to linux-media mailing list. Please also add a link to the thread with the necessary patch. Ok will do that. In addition to the above I think a readme/description file should be added to the s5p-mfc folder. The issue of firmware for v6 should be explained, so that no one is surprised that something does not work. May I suggest a little different solution? Since to not break compatibility, support for both firmware versions is needed in the driver anyway, why not simply make the new, incompatible firmware always use a different filename. Then let the driver try to load the new one first and if it fails then load the old one? This would also let you get rid of that version check by hardcoded date, as you would know which firmware type was found. Tomasz, I really like your idea. I find it both simple and elegant. This way there will be no need to rename the firmware file in the repo or by the user, if the user wishes to use the new version. Arun, what is your opinion? Best regards, Tomasz Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware
Hi Arun, I asked you to put old and new v6 firmware in separate files. You should also mention in the commit message that this new firmware will not work with the s5p-mfc driver without the patch you recently submitted to linux-media mailing list. Please also add a link to the thread with the necessary patch. In addition to the above I think a readme/description file should be added to the s5p-mfc folder. The issue of firmware for v6 should be explained, so that no one is surprised that something does not work. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, May 16, 2014 11:45 AM To: dw...@infradead.org; b...@decadent.org.uk; linux-samsung- s...@vger.kernel.org Cc: k.deb...@samsung.com; arunkk.sams...@gmail.com Subject: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware This is the newer version of s5p-mfc-v6.fw with many fixes and enhancements. Signed-off-by: Arun Kumar K arun...@samsung.com --- s5p-mfc/s5p-mfc-v6.fw | Bin 306312 - 343756 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/s5p-mfc/s5p-mfc-v6.fw b/s5p-mfc/s5p-mfc-v6.fw index 2e1179fa6d227f1c5a23f78b4834be336e579f50..9d3345fbf4abb7ea7389816916d68 57d64732380 100644 GIT binary patch literal 343756 [snip] -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware
Hi, Original Message- From: arunkk.sams...@gmail.com [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, May 16, 2014 12:00 PM Hi Kamil, On Fri, May 16, 2014 at 3:24 PM, Kamil Debski k.deb...@samsung.com wrote: Hi Arun, I asked you to put old and new v6 firmware in separate files. But wont that require a different filename other than s5p-mfc-v6.fw? Yes. But the driver still expects the same file name. Can I put the new filename as s5p-mfc-v6-v2.fw and mention in the README that the file has to be renamed to s5p-mfc-v6.fw to be used? I think this is the way to go, because the new driver (with the patch) will work with old firmware, while old driver (without the patch) will not work with the new firmware. You should also mention in the commit message that this new firmware will not work with the s5p-mfc driver without the patch you recently submitted to linux-media mailing list. Please also add a link to the thread with the necessary patch. Ok will do that. In addition to the above I think a readme/description file should be added to the s5p-mfc folder. The issue of firmware for v6 should be explained, so that no one is surprised that something does not work. Ok. Regards Arun Best wishes, -- Kamil Debski Samsung RD Institute Poland Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, May 16, 2014 11:45 AM To: dw...@infradead.org; b...@decadent.org.uk; linux-samsung- s...@vger.kernel.org Cc: k.deb...@samsung.com; arunkk.sams...@gmail.com Subject: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware This is the newer version of s5p-mfc-v6.fw with many fixes and enhancements. Signed-off-by: Arun Kumar K arun...@samsung.com --- s5p-mfc/s5p-mfc-v6.fw | Bin 306312 - 343756 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/s5p-mfc/s5p-mfc-v6.fw b/s5p-mfc/s5p-mfc-v6.fw index 2e1179fa6d227f1c5a23f78b4834be336e579f50..9d3345fbf4abb7ea7389816916d 68 57d64732380 100644 GIT binary patch literal 343756 [snip] -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2] [media] s5p-mfc: Dequeue sequence header after STREAMON
Hi Arun, From: linux-media-ow...@vger.kernel.org [mailto:linux-media- ow...@vger.kernel.org] On Behalf Of Arun Kumar K Sent: Wednesday, May 14, 2014 10:10 AM Hi Hans, On 05/14/14 12:39, Hans Verkuil wrote: On 05/14/2014 08:29 AM, Arun Kumar K wrote: MFCv6 encoder needs specific minimum number of buffers to be queued in the CAPTURE plane. This minimum number will be known only when the sequence header is generated. So we used to allow STREAMON on the CAPTURE plane only after sequence header is generated and checked with the minimum buffer requirement. But this causes a problem that we call a vb2_buffer_done for the sequence header buffer before doing a STREAON on the CAPTURE plane. How could this ever have worked? Buffers aren't queued to the driver until STREAMON is called, and calling vb2_buffer_done for a buffer that is not queued first to the driver will mess up internal data (q- queued_count for one). This worked till now because __enqueue_in_driver is called first and then start_streaming qop is called. In MFCv6, the start_streaming driver callback used to wait till sequence header interrupt is received and it used to do vb2_buffer_done in that interrupt context. So it happened after buffers are enqueued in driver and before completing the vb2_streamon. This used to still work fine until this patch was merged - b3379c6 : vb2: only call start_streaming if sufficient buffers are queued Are you testing with CONFIG_VIDEO_ADV_DEBUG set? If not, you should do so. That will check whether all the vb2 calls are balanced. BTW, that's a small typo in s5p_mfc_enc.c (search for 'inavlid'). I got it. Will post a patch fixing them. Thanks for spotting this. This problem should also come in earlier MFC firmware versions if the application calls STREAMON on CAPTURE with some delay after doing STREAMON on OUTPUT. You can also play around with the min_buffers_needed field. My rule-of-thumb is that when start_streaming is called everything should be ready to stream. It is painful for drivers to have to keep track of the 'do I have enough buffers' status. For that reason I introduced the min_buffers_needed field. What I believe you can do here is to set it initially to a large value, preventing start_streaming from being called, and once you really know the minimum number of buffers that you need it can be updated again to the actual value. If a large value is kept in min_buffers_needed, there will be some unnecessary memory initialization needed for say 16 full HD raw YUV buffers when actual needed is only 4. And once the encoding is started, updating the min_buffers_needed to actual value doesnt give any advantage as nobody checks for it after that. So the whole idea is to not enforce a worst case buffer allocation requirement beforehand itself. I hope the current scheme of things works well for the requirement. I was looking in the code of the MFC encoder and handling of this situation seems wrong to me. You say that a minimum number of buffers has to be queued for MFC encoder to work. But this number is not checked in s5p_mfc_ctx_ready in s5p_mfc_enc.c. It is only checked during reqbufs. This way it does not ensure that there is a minimum number of buffers queued. Also there is a control V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, maybe it could be used in this context? Another thing - you say that header is generated to a CAPTURE buffer before STREAMON on CAPTURE was done. Is this correct? Can the hardware/driver write to a queued buffer without streaming enabled? Hans, Sylwester? Arun, is there a way to guess the needed number of buffers from controls? Isn't this related with number of B frames? I understand how this affects the number of buffers for OUTPUT, but I thought that a single CAPTURE buffer is always enough. I understood that a generated compressed stream is no longer used after it was created and its processing is finished. I think we need some discussion on this patch. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 2/2] [media] s5p-mfc: Add support for resolution change event
Hi, Thank you for this patch. From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Wednesday, May 14, 2014 9:00 AM To: linux-me...@vger.kernel.org; linux-samsung-soc@vger.kernel.org Cc: k.deb...@samsung.com; s.nawro...@samsung.com; hverk...@xs4all.nl; laurent.pinch...@ideasonboard.com; posc...@chromium.org; arunkk.sams...@gmail.com Subject: [PATCH v5 2/2] [media] s5p-mfc: Add support for resolution change event From: Pawel Osciak posc...@chromium.org When a resolution change point is reached, queue an event to signal the userspace that a new set of buffers is required before decoding can continue. Signed-off-by: Pawel Osciak posc...@chromium.org Signed-off-by: Arun Kumar K arun...@samsung.com Acked-by: Kamil Debski k.deb...@samsung.com --- drivers/media/platform/s5p-mfc/s5p_mfc.c |8 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 6b04f17..f3a4576 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -349,8 +349,16 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, /* All frames remaining in the buffer have been extracted */ if (dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_EMPTY) { if (ctx-state == MFCINST_RES_CHANGE_FLUSH) { + static const struct v4l2_event ev_src_ch = { + .type = V4L2_EVENT_SOURCE_CHANGE, + .u.src_change.changes = + V4L2_EVENT_SRC_CH_RESOLUTION, + }; + s5p_mfc_handle_frame_all_extracted(ctx); ctx-state = MFCINST_RES_CHANGE_END; + v4l2_event_queue_fh(ctx-fh, ev_src_ch); + goto leave_handle_frame; } else { s5p_mfc_handle_frame_all_extracted(ctx); diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index 4586186..326d8db 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c @@ -851,6 +851,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh, switch (sub-type) { case V4L2_EVENT_EOS: return v4l2_event_subscribe(fh, sub, 2, NULL); + case V4L2_EVENT_SOURCE_CHANGE: + return v4l2_src_change_event_subscribe(fh, sub); default: return -EINVAL; } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] s5p-mfc: Add a control for IVF format for VP8 encoder
Hi Pawel, Hans, I think we talked some time ago on IRC about this patch. If I remember correctly, the conclusion was that it would be better to use a specific pixel formats for this kind of out codec output. Akin to: V4L2_PIX_FMT_H264 'H264' H264 video elementary stream with start codes. V4L2_PIX_FMT_H264_NO_SC 'AVC1' H264 video elementary stream without start codes. Could you confirm this? Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Thursday, March 06, 2014 7:04 AM To: linux-me...@vger.kernel.org; linux-samsung-soc@vger.kernel.org Cc: k.deb...@samsung.com; s.nawro...@samsung.com; posc...@chromium.org; arunkk.sams...@gmail.com Subject: [PATCH] [media] s5p-mfc: Add a control for IVF format for VP8 encoder From: Pawel Osciak posc...@chromium.org Add a control to enable/disable IVF output stream format for VP8 encode. Set the IVF format output to disabled as default. Signed-off-by: Pawel Osciak posc...@chromium.org Signed-off-by: Arun Kumar K arun...@samsung.com --- Documentation/DocBook/media/v4l/controls.xml|8 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |1 + drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 11 +++ drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |2 ++ drivers/media/v4l2-core/v4l2-ctrls.c|1 + include/uapi/linux/v4l2-controls.h |1 + 6 files changed, 24 insertions(+) diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index 0e1770c..07fb64a 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -3222,6 +3222,14 @@ V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD as a golden frame./entry Acceptable values are 0, 1, 2 and 3 corresponding to encoder profiles 0, 1, 2 and 3./entry /row + rowentry/entry/row + row + entry spanname=idconstantV4L2_CID_MPEG_VIDEO_VPX_IVF_FORMAT/constantn bsp;/entry + entryboolean/entry + /row + rowentry spanname=descrOutputs the VP8 encoded stream in IVF file format./entry + /row + rowentry/entry/row /tbody /tgroup diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 5c28cc3..4d17df9 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -418,6 +418,7 @@ struct s5p_mfc_vp8_enc_params { u8 rc_frame_qp; u8 rc_p_frame_qp; u8 profile; + bool ivf; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index df83cd1..a67913e 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -676,6 +676,14 @@ static struct mfc_control controls[] = { .step = 1, .default_value = 0, }, + { + .id = V4L2_CID_MPEG_VIDEO_VPX_IVF_FORMAT, + .type = V4L2_CTRL_TYPE_BOOLEAN, + .minimum = 0, + .maximum = 1, + .step = 1, + .default_value = 0, + }, }; #define NUM_CTRLS ARRAY_SIZE(controls) @@ -1636,6 +1644,9 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_VPX_PROFILE: p-codec.vp8.profile = ctrl-val; break; + case V4L2_CID_MPEG_VIDEO_VPX_IVF_FORMAT: + p-codec.vp8.ivf = ctrl-val; + break; default: v4l2_err(dev-v4l2_dev, Invalid control, id=%d, val=%d\n, ctrl-id, ctrl-val); diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index f64621a..90edb19 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c @@ -1243,6 +1243,8 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx) /* VP8 specific params */ reg = 0; + /* Bit set to 1 disables IVF stream format. */ + reg |= p_vp8-ivf ? 0 : (0x1 12); reg |= (p_vp8-imd_4x4 0x1) 10; switch (p_vp8-num_partitions) { case V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION: diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2- core/v4l2-ctrls.c index e9e12c4..19e78df 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -752,6 +752,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP:return VPX I- Frame QP Value; case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP:return VPX P
RE: [PATCH v2] [media] s5p-mfc: add init buffer cmd to MFCV6
Hi, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Tuesday, March 11, 2014 10:16 AM From: avnd kiran avnd.ki...@samsung.com Latest MFC v6 firmware requires tile mode and loop filter setting to be done as part of Init buffer command, in sync with v7. Since there are two versions of v6 firmware with different interfaces, it is differenciated using the version number read back from firmware which is a hexadecimal value based on the firmware date. Signed-off-by: avnd kiran avnd.ki...@samsung.com Signed-off-by: Arun Kumar K arun...@samsung.com --- Changes from v1 --- - Check for v6 firmware date for differenciating old and new firmware as per comments from Kamil and Sylwester. --- drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 + drivers/media/platform/s5p-mfc/regs-mfc-v7.h|2 -- drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++ drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |8 +++--- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 30 --- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h index 8d0b686..b47567c 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h @@ -132,6 +132,7 @@ #define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6 0xf448 #define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6 0xf44c #define S5P_FIMV_D_NUM_MV_V6 0xf478 +#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V60xf47c #define S5P_FIMV_D_CPB_BUFFER_ADDR_V60xf4b0 #define S5P_FIMV_D_CPB_BUFFER_SIZE_V60xf4b4 diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h index ea5ec2a..82c96fa 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h @@ -18,8 +18,6 @@ #define S5P_FIMV_CODEC_VP8_ENC_V725 /* Additional registers for v7 */ -#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V70xf47c - #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V7 0xf9e0 #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7 0xf9e4 #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V7 0xf9e8 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 4d17df9..f5404a6 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -287,6 +287,7 @@ struct s5p_mfc_priv_buf { * @warn_start: hardware error code from which warnings start * @mfc_ops: ops structure holding HW operation function pointers * @mfc_cmds:cmd structure holding HW commands function pointers + * @ver: firmware sub version * */ struct s5p_mfc_dev { @@ -330,6 +331,7 @@ struct s5p_mfc_dev { int warn_start; struct s5p_mfc_hw_ops *mfc_ops; struct s5p_mfc_hw_cmds *mfc_cmds; + int ver; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index 2475a3c..ba1d302 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c @@ -240,7 +240,6 @@ static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) /* Initialize hardware */ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) { - unsigned int ver; int ret; mfc_debug_enter(); @@ -302,12 +301,13 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) return -EIO; } if (IS_MFCV6_PLUS(dev)) - ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); + dev-ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); else - ver = mfc_read(dev, S5P_FIMV_FW_VERSION); + dev-ver = mfc_read(dev, S5P_FIMV_FW_VERSION); mfc_debug(2, MFC F/W version : %02xyy, %02xmm, %02xdd\n, - (ver 16) 0xFF, (ver 8) 0xFF, ver 0xFF); + (dev-ver 16) 0xFF, (dev-ver 8) 0xFF, + dev-ver 0xFF); s5p_mfc_clock_off(); mfc_debug_leave(); return 0; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index 90edb19..356cfe5 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c @@ -14,6 +14,7 @@ #undef DEBUG +#include linux/bcd.h #include linux/delay.h #include linux/mm.h #include linux/io.h @@ -1269,6 +1270,29 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx) return 0; } +/* Check if newer v6 firmware with changed init buffer interface */ +static bool s5p_mfc_is_v6_new(struct s5p_mfc_dev *dev) { + unsigned long cur_fw, v6_new_fw; + unsigned int y, m, d; + +
RE: [PATCH v2] [media] s5p-mfc: add init buffer cmd to MFCV6
Hi, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Tuesday, March 11, 2014 10:16 AM From: avnd kiran avnd.ki...@samsung.com Latest MFC v6 firmware requires tile mode and loop filter setting to be done as part of Init buffer command, in sync with v7. Since there are two versions of v6 firmware with different interfaces, it is differenciated using the version number read back from firmware which is a hexadecimal value based on the firmware date. MFC version has two parts major and minor. Are you sure that date is the only way to check if the interface has changed? Maybe the major number should stay the same (6) in this case, and the minor should be updates? Do you have contact with persons writing the firmware? Also, I don't see a patch with the newer firmware posted to linux-firmware. When it is going to be sent? Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: avnd kiran avnd.ki...@samsung.com Signed-off-by: Arun Kumar K arun...@samsung.com --- Changes from v1 --- - Check for v6 firmware date for differenciating old and new firmware as per comments from Kamil and Sylwester. --- drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 + drivers/media/platform/s5p-mfc/regs-mfc-v7.h|2 -- drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++ drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |8 +++--- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 30 --- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h index 8d0b686..b47567c 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h @@ -132,6 +132,7 @@ #define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6 0xf448 #define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6 0xf44c #define S5P_FIMV_D_NUM_MV_V6 0xf478 +#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V60xf47c #define S5P_FIMV_D_CPB_BUFFER_ADDR_V60xf4b0 #define S5P_FIMV_D_CPB_BUFFER_SIZE_V60xf4b4 diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h index ea5ec2a..82c96fa 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h @@ -18,8 +18,6 @@ #define S5P_FIMV_CODEC_VP8_ENC_V725 /* Additional registers for v7 */ -#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V70xf47c - #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V7 0xf9e0 #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7 0xf9e4 #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V7 0xf9e8 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 4d17df9..f5404a6 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -287,6 +287,7 @@ struct s5p_mfc_priv_buf { * @warn_start: hardware error code from which warnings start * @mfc_ops: ops structure holding HW operation function pointers * @mfc_cmds:cmd structure holding HW commands function pointers + * @ver: firmware sub version * */ struct s5p_mfc_dev { @@ -330,6 +331,7 @@ struct s5p_mfc_dev { int warn_start; struct s5p_mfc_hw_ops *mfc_ops; struct s5p_mfc_hw_cmds *mfc_cmds; + int ver; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index 2475a3c..ba1d302 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c @@ -240,7 +240,6 @@ static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) /* Initialize hardware */ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) { - unsigned int ver; int ret; mfc_debug_enter(); @@ -302,12 +301,13 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) return -EIO; } if (IS_MFCV6_PLUS(dev)) - ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); + dev-ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); else - ver = mfc_read(dev, S5P_FIMV_FW_VERSION); + dev-ver = mfc_read(dev, S5P_FIMV_FW_VERSION); mfc_debug(2, MFC F/W version : %02xyy, %02xmm, %02xdd\n, - (ver 16) 0xFF, (ver 8) 0xFF, ver 0xFF); + (dev-ver 16) 0xFF, (dev-ver 8) 0xFF, + dev-ver 0xFF); s5p_mfc_clock_off(); mfc_debug_leave(); return 0; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index 90edb19..356cfe5 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c @@ -14,6
RE: [PATCH] [media] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.
Hi, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, March 07, 2014 9:26 AM From: Pawel Osciak posc...@chromium.org Currently, for formats that are not H264, MFC driver will check the consumed stream size returned by the firmware and, based on that, will try to decide whether the bitstream buffer contained more than one frame. If the size of the buffer is larger than the consumed stream, it assumes that there are more frames in the buffer and that the buffer should be resubmitted for decode. This rarely works though and actually introduces problems, because: - v7 firmware will always return consumed stream size equal to whatever the driver passed to it when running decode (which is the size of the whole buffer), which means we will never try to resubmit, because the firmware will always tell us that it consumed all the data we passed to it; - v6 firmware will return the number of consumed bytes, but will not include the padding (stuffing) bytes that are allowed after the frame in VP8. Since there is no way of figuring out how many of those bytes follow the frame without getting the frame size from IVF headers (or somewhere else, but not from the stream itself), the driver tries to guess that padding size is not larger than 4 bytes, which is not always true; The only way to make it work is to queue only one frame per buffer from userspace and the check in the kernel is useless and wrong for VP8. MPEG4 still seems to require it, so keep it only for that format. Signed-off-by: Pawel Osciak posc...@chromium.org Signed-off-by: Arun Kumar K arun...@samsung.com --- drivers/media/platform/s5p-mfc/s5p_mfc.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index e2aac59..66c1775 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -360,7 +360,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, list); ctx-consumed_stream += s5p_mfc_hw_call(dev-mfc_ops, get_consumed_stream, dev); - if (ctx-codec_mode != S5P_MFC_CODEC_H264_DEC + if (ctx-codec_mode == S5P_MFC_CODEC_MPEG4_DEC ctx-consumed_stream + STUFF_BYTE src_buf-b-v4l2_planes[0].bytesused) { /* Run MFC again on the same buffer */ I expressed my doubts to this patch in my previous email. I think that packed PB can also be found in other codecs such as H263. So please change to the following if this is a workaround for VP8 only. (The title says that it only changes behavior of VP8 decoding, so it is misleading). - if (ctx-codec_mode != S5P_MFC_CODEC_H264_DEC + if (ctx-codec_mode != S5P_MFC_CODEC_H264_DEC + ctx-codec_mode != S5P_MFC_CODEC_VP8_DEC Did you try to revert your patch https://patchwork.linuxtv.org/patch/15448/ and checking if this fixes the problem for VP8? -- 1.7.9.5 Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] s5p-mfc: Add IOMMU support
Hi Arun, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] Sent: Tuesday, April 22, 2014 2:22 PM Hi Laurent, Thank you for the review. On Tue, Apr 22, 2014 at 5:23 PM, Laurent Pinchart laurent.pinch...@ideasonboard.com wrote: Hi Arun, Thank you for the patch. On Tuesday 22 April 2014 16:32:48 Arun Kumar K wrote: The patch adds IOMMU support for MFC driver. I've been working on an IOMMU driver lately, which led me to think about how drivers should be interfaced with IOMMUs. Runtime IOMMU handling is performed by the DMA mapping API, but in many cases (including Exynos platforms) the arm_iommu_create_mapping() and arm_iommu_attach_device() functions still need to be called explicitly by drivers, which doesn't seem a very good idea to me. Ideally IOMMU usage should be completely transparent for bus master drivers, without requiring any driver modification to use the IOMMU. What would you think about improving the Exynos IOMMU driver to create the mapping and attach the device instead of having to modify all bus master drivers ? See the ipmmu_add_device() function in http://www.spinics.net/lists/linux-sh/msg30488.html for a possible implementation. Yes that would be a better solution. But as far as I know, exynos platforms has few more complications where multiple IOMMUs are present for single IP. The exynos iommu work is still under progress and KyonHo Cho will have some inputs / comments on this. This seems to me a valid usecase which can be considered for exynos iommu also. Arun, could you tell me how did you test this? I think that the MFC driver should not be modified to use iommu. Dma_mapping should be used. On Tizenorg there is a 3.10 kernel with an iommu driver that works with MFC without any patches to the MFC drvier. I disagree to merging this patch, sorry. This should be done the correct way. NACK. Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: Arun Kumar K arun...@samsung.com --- This patch is tested on IOMMU support series [1] posted by KyonHo Cho. [1] https://lkml.org/lkml/2014/3/14/9 --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 33 +++ 1 file changed, 33 insertions(+) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 89356ae..1f248ba 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -32,11 +32,18 @@ #include s5p_mfc_opr.h #include s5p_mfc_cmd.h #include s5p_mfc_pm.h +#ifdef CONFIG_EXYNOS_IOMMU +#include asm/dma-iommu.h +#endif #define S5P_MFC_NAME s5p-mfc #define S5P_MFC_DEC_NAME s5p-mfc-dec #define S5P_MFC_ENC_NAME s5p-mfc-enc +#ifdef CONFIG_EXYNOS_IOMMU +static struct dma_iommu_mapping *mapping; #endif + int debug; module_param(debug, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, Debug level - higher value produces more verbose messages); @@ -1013,6 +1020,23 @@ static void *mfc_get_drv_data(struct platform_device *pdev); static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) { +#ifdef CONFIG_EXYNOS_IOMMU + struct device *mdev = dev-plat_dev-dev; + + mapping = arm_iommu_create_mapping(platform_bus_type, 0x2000, + SZ_256M); + if (mapping == NULL) { + mfc_err(IOMMU mapping failed\n); + return -EFAULT; + } + mdev-dma_parms = devm_kzalloc(dev-plat_dev-dev, + sizeof(*mdev-dma_parms), GFP_KERNEL); + dma_set_max_seg_size(mdev, 0xu); + arm_iommu_attach_device(mdev, mapping); + + dev-mem_dev_l = dev-mem_dev_r = mdev; + return 0; +#else unsigned int mem_info[2] = { }; dev-mem_dev_l = devm_kzalloc(dev-plat_dev-dev, @@ -1049,6 +1073,7 @@ static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) return -ENOMEM; } return 0; +#endif } /* MFC probe function */ @@ -1228,6 +1253,10 @@ err_mem_init_ctx_1: vb2_dma_contig_cleanup_ctx(dev-alloc_ctx[0]); err_res: s5p_mfc_final_pm(dev); +#ifdef CONFIG_EXYNOS_IOMMU + if (mapping) + arm_iommu_release_mapping(mapping); +#endif pr_debug(%s-- with error\n, __func__); return ret; @@ -1256,6 +1285,10 @@ static int s5p_mfc_remove(struct platform_device *pdev) put_device(dev-mem_dev_r); } +#ifdef CONFIG_EXYNOS_IOMMU + if (mapping) + arm_iommu_release_mapping(mapping); +#endif s5p_mfc_final_pm(dev); return 0; } -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2 1/2] v4l: Add resolution change event.
Hi Pawel, From: Pawel Osciak [mailto:posc...@chromium.org] Sent: Monday, April 21, 2014 12:27 PM To: Arun Kumar K Cc: linux-me...@vger.kernel.org; linux-samsung-soc; Kamil Debski; Sylwester Nawrocki; Hans Verkuil; Laurent Pinchart Subject: Re: [PATCH v2 1/2] v4l: Add resolution change event. As a side note, because this is not really codified in the API, I would like this event to indicate not only resolution change mid-stream, but also detection of initial resolution, which should be a subset of resolution change. I think this would make sense for the codec interface: Video decode: 1. S_FMT to given codec on OUTPUT queue. 2. REQBUFS(n) and STREAMON on OUTPUT queue. 3. Keep QBUFing until we get an resolution change event on the CAPTURE queue; until then, the driver/codec HW will operate on the OUTPUT queue only and try to detect relevant headers in the OUTPUT buffers, and will send resolution change event once it finds resolution, profile, etc. info). DQEVENT. 4. G_FMT on CAPTURE to get the discovered output format (resolution), REQBUFS and STREAMON on the CAPTURE queue. 5. Normal mem-to-mem decoding. 6. If a resolution change event arrives on CAPTURE queue, DQEVENT, STREAMOFF, REQBUFS(0) only on CAPTURE queue, and goto 4. OUTPUT queue operates completely independently of this. Also, this event should invariably indicate all of the below: - all output buffers from before resolution change are already ready on the CAPTURE queue to DQBUF (so it's ready to REQBUFS(0) after DQBUFs), and - there will be no more new ready buffers on the CAPTURE queue until the streamoff-reqbufs(0)-g_fmt-reqbufs()-streamon is performed, and - OUTPUT queue is completely independent of all of the above and can be still used as normal, i.e. stream buffers can still keep being queued at any stage of the resolution change and they will be decoded after resolution change sequence is finished; If we all agree to the above, I will prepare a subsequent patch for the documentation to include the above. If I understand correctly this will keep the old application working. By this I mean application that do not use events and rely on the current mechanism to detect initial header parsing and resolution change. If backward compatibility is kept I am all for the changes proposed by you. Thanks, Pawel Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v2 1/2] v4l: Add resolution change event.
Hi Pawel, From: Pawel Osciak [mailto:posc...@chromium.org] Sent: Tuesday, April 22, 2014 9:46 AM To: Kamil Debski Cc: Arun Kumar K; linux-me...@vger.kernel.org; linux-samsung-soc; Sylwester Nawrocki; Hans Verkuil; Laurent Pinchart Subject: Re: [PATCH v2 1/2] v4l: Add resolution change event. Hi Kamil, On Tue, Apr 22, 2014 at 4:34 PM, Kamil Debski k.deb...@samsung.com wrote: Hi Pawel, From: Pawel Osciak [mailto:posc...@chromium.org] Sent: Monday, April 21, 2014 12:27 PM To: Arun Kumar K Cc: linux-me...@vger.kernel.org; linux-samsung-soc; Kamil Debski; Sylwester Nawrocki; Hans Verkuil; Laurent Pinchart Subject: Re: [PATCH v2 1/2] v4l: Add resolution change event. As a side note, because this is not really codified in the API, I would like this event to indicate not only resolution change mid- stream, but also detection of initial resolution, which should be a subset of resolution change. I think this would make sense for the codec interface: Video decode: 1. S_FMT to given codec on OUTPUT queue. 2. REQBUFS(n) and STREAMON on OUTPUT queue. 3. Keep QBUFing until we get an resolution change event on the CAPTURE queue; until then, the driver/codec HW will operate on the OUTPUT queue only and try to detect relevant headers in the OUTPUT buffers, and will send resolution change event once it finds resolution, profile, etc. info). DQEVENT. 4. G_FMT on CAPTURE to get the discovered output format (resolution), REQBUFS and STREAMON on the CAPTURE queue. 5. Normal mem-to-mem decoding. 6. If a resolution change event arrives on CAPTURE queue, DQEVENT, STREAMOFF, REQBUFS(0) only on CAPTURE queue, and goto 4. OUTPUT queue operates completely independently of this. Also, this event should invariably indicate all of the below: - all output buffers from before resolution change are already ready on the CAPTURE queue to DQBUF (so it's ready to REQBUFS(0) after DQBUFs), and - there will be no more new ready buffers on the CAPTURE queue until the streamoff-reqbufs(0)-g_fmt-reqbufs()-streamon is performed, and - OUTPUT queue is completely independent of all of the above and can be still used as normal, i.e. stream buffers can still keep being queued at any stage of the resolution change and they will be decoded after resolution change sequence is finished; If we all agree to the above, I will prepare a subsequent patch for the documentation to include the above. If I understand correctly this will keep the old application working. By this I mean application that do not use events and rely on the current mechanism to detect initial header parsing and resolution change. If backward compatibility is kept I am all for the changes proposed by you. MFC codec depends on the userspace to parse the stream and pass the stream header with resolution info before calling G_FMT. So if it ignores the events but keeps doing this, things should keep working I think, as the G_FMT should still work as before. This event will help userspace that doesn't want to bother itself with parsing the stream to know if the right header was queued and rely on events to know when to call G_FMT instead. What do you think? Am I missing something? Do you think this will work with all MFC versions? I guess that your focus is on the newer MFC version such as v6 or even v7. I had worked mostly with the v5 version and I am not sure how well it will handle the situation when it does not receive the header as the first frame. Do you have a target with v5 of MFC at hand? I really like your idea. If you haven't got the possibility to check how it works on v5 then I suggest you go ahead with patches and later I will do some testing on MFC v5. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.
Hi Arun, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun Kumar K Sent: Friday, March 07, 2014 9:26 AM From: Pawel Osciak posc...@chromium.org Currently, for formats that are not H264, MFC driver will check the consumed stream size returned by the firmware and, based on that, will try to decide whether the bitstream buffer contained more than one frame. If the size of the buffer is larger than the consumed stream, it assumes that there are more frames in the buffer and that the buffer should be resubmitted for decode. This rarely works though and actually introduces problems, because: - v7 firmware will always return consumed stream size equal to whatever the driver passed to it when running decode (which is the size of the whole buffer), which means we will never try to resubmit, because the firmware will always tell us that it consumed all the data we passed to it; This does sound like a hardware bug/feature. So in v7 the buffer is never resubmitted, yes? And this patch makes no difference for v7? - v6 firmware will return the number of consumed bytes, but will not include the padding (stuffing) bytes that are allowed after the frame in VP8. Since there is no way of figuring out how many of those bytes follow the frame without getting the frame size from IVF headers (or somewhere else, but not from the stream itself), the driver tries to guess that padding size is not larger than 4 bytes, which is not always true; How about v5 of MFC? I need to do some additional testing, as I don't want to introduce any regressions. I remember that this check was a result of a fair amount of work and testing with v5. The only way to make it work is to queue only one frame per buffer from userspace and the check in the kernel is useless and wrong for VP8. MPEG4 still seems to require it, so keep it only for that format. Is your goal to give more than one frame in a single buffer and have the buffer resubmitted? Or the opposite - you are getting the frame resubmitted without the need? By the contents of this patch I guess the latter, on the other hand I do remember that at some point the idea was to be able to queue more than one frame per buffer. I don't remember exactly who was opting for the ability to queue more frames in a single buffer... Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: Pawel Osciak posc...@chromium.org Signed-off-by: Arun Kumar K arun...@samsung.com --- drivers/media/platform/s5p-mfc/s5p_mfc.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index e2aac59..66c1775 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -360,7 +360,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, list); ctx-consumed_stream += s5p_mfc_hw_call(dev-mfc_ops, get_consumed_stream, dev); - if (ctx-codec_mode != S5P_MFC_CODEC_H264_DEC + if (ctx-codec_mode == S5P_MFC_CODEC_MPEG4_DEC ctx-consumed_stream + STUFF_BYTE src_buf-b-v4l2_planes[0].bytesused) { /* Run MFC again on the same buffer */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] s5p-mfc: add init buffer cmd to MFCV6
Hi Arun, From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] Sent: Friday, March 07, 2014 12:10 PM Hi Sylwester, On Fri, Mar 7, 2014 at 2:59 PM, Sylwester Nawrocki s.nawro...@samsung.com wrote: Hi, On 07/03/14 09:31, Arun Kumar K wrote: From: avnd kiran avnd.ki...@samsung.com Latest MFC v6 firmware requires tile mode and loop filter setting to be done as part of Init buffer command, in sync with v7. So, move these settings out of decode options reg. Also, make this register definition applicable from v6 onwards. Signed-off-by: avnd kiran avnd.ki...@samsung.com Signed-off-by: Arun Kumar K arun...@samsung.com Will the driver also work with older version of the firmware after this change ? If not, shouldn't things like this be done depending on what firmware version is loaded ? The original code was for the initial version of v6 firmware. After that the v6 firmware has got many fixes and updates which also got updated in the products running the same. As such there are no official multiple versions of v6 firmware, but only fixes / updates to older version. I will update the s5p-mfc-v6.fw in the linux-firmware also with the newer version. Hope that will be fine. Unfortunately, I share the same concerns as Sylwester. We have two problems: 1) new kernel + old firmware In this case, someone will update the kernel and find out that video decoding is not working. An assumption that I think is common, is that updating the kernel should not break anything. If it was working with the previous version it should work with the next. The solution I can suggest is that a check which firmware version is used has to be implemented. Maybe you can use the date of firmware to do this check? 2) old kernel + new firmware I see no clear solution to this problem. If the kernel is old and the firmware is behaving differently, the video decoding will not work. I can guess that this case would be less common, but still a person can update the firmware and leave the old kernel. Changing the firmware can be done by replacing a single file. In addition to the above, you need to clearly specify in the linux-firmware.git what is going on. A readme file is a must. Maybe a second v6 firmware file should be included? Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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 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 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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
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 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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 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 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 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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 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 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 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 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the seventh version of this patchset. First and most significant change 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. Thank you to everyone who joined the discussion, reviewed the patched and contributed to making the code and consequently the Linux Kernel better. Best wishes, Kamil Debski -- 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 instead of (1 x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray
[PATCH v7 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 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 4210 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 | 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 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
RE: [PATCH v6 5/8] phy: Add new Exynos USB PHY driver
Hi Kishon, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, March 03, 2014 3:28 PM Hi, On Wednesday 29 January 2014 10:59 PM, Kamil Debski wrote: Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Can the PHY part of this series be merged independently of the controller part? I see no problems with merging the PHY part independently. However, I would like to post an updated version of these patches. I am working on them now and should send them tomorrow. Best wishes, -- Kamil Debski Samsung RD Institute Poland Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 55 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 257 drivers/phy/phy-exynos4x12-usb2.c | 323 drivers/phy/phy-samsung-usb2.c | 227 ++ drivers/phy/phy-samsung-usb2.h | 67 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..6668c41 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,58 @@ 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 clocks is required by the phy module + - next for each of the phys a clock has to be assigned, this clock + will be used to determine clocking frequency for the phys + (the labels are specified in the paragraph below) + +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,exynos4212-usb2-phy; + reg = 0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + 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..9f5826e --- /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
RE: [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Hi Olof, Thank you for your review. From: Olof Johansson [mailto:o...@lixom.net] Sent: Wednesday, January 29, 2014 9:55 PM Hi, On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski k.deb...@samsung.com wrote: Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..25e199a 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -12,6 +12,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be usbhost. + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a +consecutive number. Also it should contain phys and phy-names entries +specifying the phy used by the port. Optional properties: - samsung,vbus-gpio: if present, specifies the GPIO that @@ -27,6 +31,15 @@ Example: clocks = clock 285; clock-names = usbhost; + + #address-cells = 1; + #size-cells = 0; + port@0 { + reg = 0; + phys = usb2phy 1; + phy-names = host; + status = disabled; + }; }; OHCI [...] @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev) samsung,exynos5440-ehci)) goto skip_phy; - phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(pdev-dev, no platform data or transceiver defined\n); - return -EPROBE_DEFER; - } else { - exynos_ehci-phy = phy; - exynos_ehci-otg = phy-otg; + for_each_available_child_of_node(pdev-dev.of_node, child) { + err = of_property_read_u32(child, reg, phy_number); + if (err) { + dev_err(pdev-dev, Failed to parse device tree\n); + of_node_put(child); + return err; + } + if (phy_number = PHY_NUMBER) { + dev_err(pdev-dev, Failed to parse device tree - number out of range\n); + of_node_put(child); + return -EINVAL; + } + phy = devm_of_phy_get(pdev-dev, child, 0); + of_node_put(child); + if (IS_ERR(phy)) { + dev_err(pdev-dev, Failed to get phy number %d, + phy_number); + return PTR_ERR(phy); + } + exynos_ehci-phy[phy_number] = phy; this looks like it is now breaking older device trees, where ports might not be described. Since device tree interfaces need to be backwards compatible, you still need to handle the old case of not having ports described. There are two ways of doing this: 1. Fall back to the old behavior if there are no ports 2. Use a new compatible value for the new model with port subnodes, and if the old compatible value is used, then fall back to the old behavior. I'm guessing (1) might be easiest since you can check for the presence of #address-cells to tell if this is just an old style node, or if it's a new-style node without any ports below it. The ultimate goal is to remove the old phy driver. Unfortunately this has to be synced with the new USB3 phy driver by Vivek Gautam. I think he is also close to completion. What about this case? In the end the old driver will be removed and no longer be supported. Having backward compatibility in mind, it is possible to have the old and the new phy driver together in one kernel release. But do we want to have two drivers doing the same thing at the same time? Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Hi Alan, Thank you for your review. From: Alan Stern [mailto:st...@rowland.harvard.edu] Sent: Wednesday, January 29, 2014 9:43 PM On Wed, 29 Jan 2014, Kamil Debski wrote: Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..25e199a 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -12,6 +12,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be usbhost. + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a +consecutive number. Also it should contain phys and phy-names entries +specifying the phy used by the port. What is the reg entry number used for? As far as I can see, it isn't used for anything. In which case, why have it at all? Tomasz Figa already commented this. I agree with him, that this should be better described in the documentation. @@ -42,10 +42,10 @@ static const char hcd_name[] = ehci-exynos; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; You have removed all the OTG stuff from the driver. This wasn't mentioned in the patch description, and it has no connection with the PHY work. Maybe I'll explain more about what are we trying to achieve. The goal is to replace the old phy driver with the new one. In the old driver it was difficult to add support to new SoC. It also had issues with having device and host working together. You're right that until the old phy driver is removed support for the it should remain. To be able to remove the old driver both new USB2 and new USB3 phy drivers have to be ready. The USB3 driver is written by Vivek Gautam and as I see it, he is also close to completion. Regarding the otg part. The old phy driver is the only provider of the otg structure. It sets the host field of the structure. It is then used by samsung_usb2phy_init (drivers/usb/phy/phy-samsung-usb2.c) to check which driver is requesting the phy (is it host or device). In the new driver this is determined by the entry in device tree. So no need to check the otg struct and strstr (!) to check if dev_name is ehci, ohci or other, like the old driver. + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, can't request ehci vbus gpio %d, gpio); } +static int exynos_phys_on(struct phy *p[]) { + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i 0; i--) + if (p[i]) + phy_power_off(p[i]); This loop runs while i 0. Therefore you will never turn off the power to p[0]. Ups, my bad. Thank you for spotting this. @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev) samsung,exynos5440-ehci)) goto skip_phy; - phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); You omitted this line from the new error returns below. I see. - dev_warn(pdev-dev, no platform data or transceiver defined\n); - return -EPROBE_DEFER; - } else { - exynos_ehci-phy = phy; - exynos_ehci-otg = phy-otg; + for_each_available_child_of_node(pdev-dev.of_node, child) { + err = of_property_read_u32(child, reg, phy_number); + if (err) { + dev_err(pdev-dev, Failed to parse device tree\n); + of_node_put(child); + return err; Here, for example. Wouldn't it be better to goto fail_clk? Right, I will fix this. Thank you. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v6 3/8] dts: Add usb2phy to Exynos 4
Hi Olof, From: Olof Johansson [mailto:o...@lixom.net] Sent: Wednesday, January 29, 2014 9:51 PM On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski k.deb...@samsung.com wrote: Add support to PHY of USB2 of the Exynos 4 SoC. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/arm/samsung/pmu.txt|2 ++ arch/arm/boot/dts/exynos4.dtsi | 31 arch/arm/boot/dts/exynos4210.dtsi | 17 +++ arch/arm/boot/dts/exynos4x12.dtsi | 17 +++ 4 files changed, 67 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt b/Documentation/devicetree/bindings/arm/samsung/pmu.txt index 307e727..a76f91d 100644 --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers Properties: - name : should be 'syscon'; - compatible : should contain two values. First value must be one from following list: + - samsung,exynos4210-pmu - for Exynos4210 SoC, + - samsung,exynos4x12-pmu - for Exynos4212 SoC, - samsung,exynos5250-pmu - for Exynos5250 SoC, - samsung,exynos5420-pmu - for Exynos5420 SoC. second value must be always syscon. This and other PMU related bindings/dts changes should probably go in separate patch(es) instead of being snuck in with USB changes. O, I will move this to a separate patch. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 0/8] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the sixth version of the patchset. It adds a new Exynos USB 2.0 PHY driver. The driver uses the Generic PHY Framework. Again, I would like to thank everyone who commented and read through the fifth version of the patchset. Your input is very much appreciated. The last version had two alternative approaches included. This allowed a comparison between these approaches to the Exynos USB 2.0 PHY driver. The original idea was chosen as it gave the optimal compromise between code readability and size of the driver. These patchset depend on a patch by Leela Krishna Amudala. [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi files [1]. Best wishes, Kamil Debski [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html 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 instead of (1 x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray whitespace - move of_phy_provider_register() to the end of probe - add a regular error return code to the rate_to_clk functions - cleanup code and remove unused code - change struct names to avoid collisions - add mechanism to support multiple phys by the ehci driver Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove empty line that was wrongfully added) - fixes
[PATCH v6 1/8] 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 645c867..a1d4387 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -258,8 +258,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, @@ -268,20 +268,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); @@ -301,6 +298,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() * @@ -388,7 +415,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); if (IS_ERR(phy)) { dev_err(dev, unable to find phy\n); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index e273e5a..5cffc69 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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, @@ -245,6 +246,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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 6/8] phy: Add support for S5PV210 to the Exynos USB PHY driver
From: Mateusz Krawczuk mat.krawc...@gmail.com Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver. Signed-off-by: Mateusz Krawczuk m.krawc...@partner.samsung.com [k.deb...@samsung.com: cleanup and commit description] [k.deb...@samsung.com: make changes accordingly to the mailing list comments] [k.deb...@samsung.com: fix bug with setting of clk register] Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 10 + drivers/phy/Makefile |1 + drivers/phy/phy-s5pv210-usb2.c | 199 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 218 insertions(+) create mode 100644 drivers/phy/phy-s5pv210-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 6668c41..710d41f 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -26,6 +26,7 @@ Samsung S5P/EXYNOS SoC series USB PHY Required properties: - compatible : should be one of the listed compatibles: + - samsung,s5pv210-usb2-phy - samsung,exynos4210-usb2-phy - samsung,exynos4x12-usb2-phy - reg : a list of registers used by phy driver diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3691d24..a5554b5 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -73,6 +73,16 @@ config PHY_SAMSUNG_USB2 particular SoCs has to be enabled in addition to this driver. Number and type of supported phys depends on the SoC. +config PHY_S5PV210_USB2 + bool Support for S5PV210 + depends on PHY_SAMSUNG_USB2 + depends on ARCH_S5PV210 + help + Enable USB PHY support for S5PV210. 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 S5PV210 two phys + are available - device and host. + config PHY_EXYNOS4210_USB2 bool Support for Exynos 4210 depends on PHY_SAMSUNG_USB2 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 69d0b3f2..d738f65 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o +obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c new file mode 100644 index 000..08e5094 --- /dev/null +++ b/drivers/phy/phy-s5pv210-usb2.c @@ -0,0 +1,199 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Authors: 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 phy-samsung-usb2.h + +/* Exynos USB PHY registers */ + +/* PHY power control */ +#define S5PV210_UPHYPWR0x0 + +#define S5PV210_UPHYPWR_PHY0_SUSPEND BIT(0) +#define S5PV210_UPHYPWR_PHY0_PWR BIT(3) +#define S5PV210_UPHYPWR_PHY0_OTG_PWR BIT(4) +#define S5PV210_UPHYPWR_PHY0 ( \ + S5PV210_UPHYPWR_PHY0_SUSPEND | \ + S5PV210_UPHYPWR_PHY0_PWR | \ + S5PV210_UPHYPWR_PHY0_OTG_PWR) + +#define S5PV210_UPHYPWR_PHY1_SUSPEND BIT(6) +#define S5PV210_UPHYPWR_PHY1_PWR BIT(7) +#define S5PV210_UPHYPWR_PHY1 ( \ + S5PV210_UPHYPWR_PHY1_SUSPEND | \ + S5PV210_UPHYPWR_PHY1_PWR) + +/* PHY clock control */ +#define S5PV210_UPHYCLK0x4 + +#define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 0) +#define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 0) +#define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 0) +#define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 0) + +#define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2) +#define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4) +#define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7) + +/* PHY reset control */ +#define S5PV210_UPHYRST0x8 + +#define S5PV210_URSTCON_PHY0 BIT(0) +#define S5PV210_URSTCON_OTG_HLINK BIT(1) +#define S5PV210_URSTCON_OTG_PHYLINKBIT(2) +#define S5PV210_URSTCON_PHY1_ALL BIT(3) +#define S5PV210_URSTCON_HOST_LINK_ALL BIT(4) + +/* Isolation, configured in the power management unit */ +#define
[PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..25e199a 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -12,6 +12,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be usbhost. + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Optional properties: - samsung,vbus-gpio: if present, specifies the GPIO that @@ -27,6 +31,15 @@ Example: clocks = clock 285; clock-names = usbhost; + + #address-cells = 1; + #size-cells = 0; + port@0 { + reg = 0; + phys = usb2phy 1; + phy-names = host; + status = disabled; + }; }; OHCI diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index d1d8c47..7c35501 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include linux/module.h #include linux/of.h #include linux/of_gpio.h +#include linux/phy/phy.h #include linux/platform_device.h #include linux/usb/phy.h #include linux/usb/samsung_usb_phy.h #include linux/usb.h #include linux/usb/hcd.h -#include linux/usb/otg.h #include ehci.h @@ -42,10 +42,10 @@ static const char hcd_name[] = ehci-exynos; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, can't request ehci vbus gpio %d, gpio); } +static int exynos_phys_on(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i 0; i--) + if (p[i]) + phy_power_off(p[i]); + + return ret; +} + +static int exynos_phys_off(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_off(p[i]); + + return ret; +} + static int exynos_ehci_probe(struct platform_device *pdev) { struct exynos_ehci_hcd *exynos_ehci; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + struct phy *phy; + struct device_node *child; + int phy_number; int irq; int err; @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev) samsung,exynos5440-ehci)) goto skip_phy; - phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(pdev-dev, no platform data or transceiver defined\n); - return -EPROBE_DEFER; - } else { - exynos_ehci-phy = phy; - exynos_ehci-otg = phy-otg; + for_each_available_child_of_node(pdev-dev.of_node, child) { + err = of_property_read_u32(child, reg, phy_number); + if (err) { + dev_err(pdev-dev, Failed to parse device tree\n); + of_node_put(child); + return err; + } + if (phy_number = PHY_NUMBER) { + dev_err(pdev-dev, Failed to parse device tree - number out of range\n); + of_node_put(child); + return -EINVAL; + } + phy = devm_of_phy_get(pdev-dev, child, 0); + of_node_put(child); + if (IS_ERR(phy)) { + dev_err(pdev-dev, Failed to get phy number %d, + phy_number); + return PTR_ERR(phy
[PATCH v6 3/8] dts: Add usb2phy to Exynos 4
Add support to PHY of USB2 of the Exynos 4 SoC. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/arm/samsung/pmu.txt|2 ++ arch/arm/boot/dts/exynos4.dtsi | 31 arch/arm/boot/dts/exynos4210.dtsi | 17 +++ arch/arm/boot/dts/exynos4x12.dtsi | 17 +++ 4 files changed, 67 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt b/Documentation/devicetree/bindings/arm/samsung/pmu.txt index 307e727..a76f91d 100644 --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers Properties: - name : should be 'syscon'; - compatible : should contain two values. First value must be one from following list: + - samsung,exynos4210-pmu - for Exynos4210 SoC, + - samsung,exynos4x12-pmu - for Exynos4212 SoC, - samsung,exynos5250-pmu - for Exynos5250 SoC, - samsung,exynos5420-pmu - for Exynos5420 SoC. second value must be always syscon. diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index a73eeb5..031d07a 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -253,6 +253,17 @@ status = disabled; }; + usbotg@1248 { + compatible = samsung,s3c6400-hsotg; + reg = 0x1248 0x2; + interrupts = 0 71 0; + clocks = clock 305; + clock-names = otg; + phys = usb2phy 0; + phy-names = usb2-phy; + status = disabled; + }; + ehci@1258 { compatible = samsung,exynos4210-ehci; reg = 0x1258 0x100; @@ -260,6 +271,26 @@ clocks = clock 304; clock-names = usbhost; status = disabled; + #address-cells = 1; + #size-cells = 0; + port@0 { + phys = usb2phy 1; + phy-names = host; + reg = 0; + status = disabled; + }; + port@1 { + phys = usb2phy 2; + phy-names = hsic0; + reg = 1; + status = disabled; + }; + port@2 { + phys = usb2phy 3; + phy-names = hsic1; + reg = 2; + status = disabled; + }; }; ohci@1259 { diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi index 057d682..f9d06bb 100644 --- a/arch/arm/boot/dts/exynos4210.dtsi +++ b/arch/arm/boot/dts/exynos4210.dtsi @@ -155,4 +155,21 @@ samsung,lcd-wb; }; }; + + pmu_reg: syscon@1002 { + compatible = samsung,exynos4210-pmu, syscon; + reg = 0x1002 0x4000; + }; + + usb2phy: phy@125B { + compatible = samsung,exynos4210-usb2-phy; + reg = 0x125B 0x100; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + status = disabled; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; + }; }; diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi index ad531fe..63b0fe5 100644 --- a/arch/arm/boot/dts/exynos4x12.dtsi +++ b/arch/arm/boot/dts/exynos4x12.dtsi @@ -176,4 +176,21 @@ }; }; }; + + pmu_reg: syscon@1002 { + compatible = samsung,exynos4x12-pmu, syscon; + reg = 0x1002 0x4000; + }; + + usb2phy: phy@125B { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125B 0x100; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + status = disabled; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; + }; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 5/8] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB 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| 55 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 257 drivers/phy/phy-exynos4x12-usb2.c | 323 drivers/phy/phy-samsung-usb2.c | 227 ++ drivers/phy/phy-samsung-usb2.h | 67 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..6668c41 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,58 @@ 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 clocks is required by the phy module + - next for each of the phys a clock has to be assigned, this clock + will be used to determine clocking frequency for the phys + (the labels are specified in the paragraph below) + +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,exynos4212-usb2-phy; + reg = 0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + 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..9f5826e --- /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
[PATCH v6 2/8] 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 a1d4387..6e32fb0 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -468,6 +468,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_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 5cffc69..b17d6d2 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -147,6 +147,8 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) } struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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); @@ -238,6 +240,12 @@ static inline struct phy *devm_phy_get(struct device *dev, const char *string) 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-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 7/8] 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 | 406 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 426 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 710d41f..d1b534f 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -29,6 +29,7 @@ Required properties: - samsung,s5pv210-usb2-phy - 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 a5554b5..645ed66 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -102,4 +102,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 d738f65..fe7aaee 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= phy-samsung-usb2.o obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-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..2603d5e --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,406 @@ +/* + * 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
RE: [PATCH] [media] s5p-mfc: Add Horizontal and Vertical search range for Video Macro Blocks
/s5p-mfc/s5p_mfc_opr_v6.c @@ -727,14 +727,10 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx) WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6); /* setting for MV range [16, 256] */ - reg = 0; - reg = ~(0x3FFF); - reg = 256; + reg = (p-horz_range 0x3fff); /* conditional check in app */ WRITEL(reg, S5P_FIMV_E_MV_HOR_RANGE_V6); Please add a S5P_FIMV_E_MV_HOR_RANGE_V6_MASK or something instead of this magic number. - reg = 0; - reg = ~(0x3FFF); - reg = 256; + reg = (p-vert_range 0x3fff); /* conditional check in app */ Please add a S5P_FIMV_E_MV_VER_RANGE_V6_MASK or something instead of this magic number. WRITEL(reg, S5P_FIMV_E_MV_VER_RANGE_V6); WRITEL(0x0, S5P_FIMV_E_FRAME_INSERTION_V6); diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2- core/v4l2-ctrls.c index fb46790..7cf23d5 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -735,6 +735,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_DEC_PTS: return Video Decoder PTS; case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return Video Decoder Frame Count; case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return Initial Delay for VBV Control; + case V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE: return hor search range of video MB; This should be property capitalised. Please mention the motion vectors too. + case V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE: return vert search range of video MB; This too should be property capitalised. Please mention the motion vectors too. case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return Repeat Sequence Header; /* VPX controls */ @@ -905,6 +907,18 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *min = 0; *max = *step = 1; break; + case V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE: + *type = V4L2_CTRL_TYPE_INTEGER; + *min = 16; + *max = 128; + *step = 16; + break; + case V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE: + *type = V4L2_CTRL_TYPE_INTEGER; + *min = 16; + *max = 128; + *step = 16; + break; case V4L2_CID_PAN_RESET: case V4L2_CID_TILT_RESET: case V4L2_CID_FLASH_STROBE: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 1666aab..bcce536 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -372,6 +372,8 @@ enum v4l2_mpeg_video_multi_slice_mode { #define V4L2_CID_MPEG_VIDEO_DEC_FRAME (V4L2_CID_MPEG_BASE+224) #define V4L2_CID_MPEG_VIDEO_VBV_DELAY (V4L2_CID_MPEG_BASE+225) #define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226) +#define V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227) +#define V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228) #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300) #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301) -- 1.7.9.5 Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support
Hi Kishon, Thank you for your review. From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, January 06, 2014 11:24 AM Hi, On Friday 20 December 2013 06:54 PM, Kamil Debski wrote: This the alternative version of the support for Exynos 421x USB 2.0 PHY in the Generic PHY framework. In this version the support for Exynos 4210 and 4212 was joined into one file. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Hi, Me and Kishon were discussing for quite a long time the way how Exynos 4 should be handled. I have decided to post the original patches and try to make an alternative version with support for Exynos 4210 and 4212 joined in one file. I have prepared two versions. The first one has 506 lines (vs 563 when two files are used). When doing the second version I was a little more aggresive in removing code. This was done at a cost of adding if's deciding which SoC version the driver is dealing with in some internal functions. This resulted in a better number of removed lines - the second version has only 452 lines (vs 563 original and 506 version 1). Alright.. If the alternate approach doesn't give too much of advantage, lets stick with the original one. I would recommend creating a documentation (Documentation/phy/?) for the samsung PHY since that actually creates a layer on top of generic PHY framework. That would help while adding new samsung PHY drivers. Ok, I will prepare an updated set of patches with the documentation added. Also I will fix other issues you pointed out in reply to other patches from this series. Btw thank you for preparing alternate versions for your original patches. No problem :) Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 3/9] phy: Add new Exynos USB 2.0 PHY driver
Hi, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, January 06, 2014 11:12 AM Hi, On Friday 20 December 2013 06:54 PM, Kamil Debski wrote: 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 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 55 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 257 drivers/phy/phy-exynos4212-usb2.c | 306 drivers/phy/phy-samsung-usb2.c | 226 +++ drivers/phy/phy-samsung-usb2.h | 67 + 7 files changed, 943 insertions(+) create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h . . snip . . diff --git a/drivers/phy/phy-samsung-usb2.h b/drivers/phy/phy-samsung-usb2.h new file mode 100644 index 000..ab89f91 --- /dev/null +++ b/drivers/phy/phy-samsung-usb2.h @@ -0,0 +1,67 @@ +/* + * 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. + */ + +#ifndef _PHY_EXYNOS_USB2_H +#define _PHY_EXYNOS_USB2_H + +#include linux/clk.h +#include linux/phy/phy.h +#include linux/device.h +#include linux/regmap.h +#include linux/spinlock.h + +#define KHZ 1000 +#define MHZ (KHZ * KHZ) + +struct samsung_usb2_phy_driver; +struct samsung_usb2_phy_instance; +struct samsung_usb2_phy_config; + +struct samsung_usb2_phy_instance { + const struct samsung_usb2_common_phy *cfg; + struct clk *clk; + struct phy *phy; + struct samsung_usb2_phy_driver *drv; + unsigned long rate; + u32 clk_reg_val; + bool enabled; +}; + +struct samsung_usb2_phy_driver { + const struct samsung_usb2_phy_config *cfg; + struct clk *clk; + struct device *dev; + void __iomem *reg_phy; + struct regmap *reg_pmu; + struct regmap *reg_sys; + spinlock_t lock; + struct samsung_usb2_phy_instance instances[0]; I think having instances as array here would allocate more space while allocating 'samsung_usb2_phy_driver' in 'samsung_usb2_phy_probe'. I am not sure if I understand you correctly here. Maybe I will explain what I intended to write. An array with size 0 at the end of a structure takes no space in the structure. The benefit of using it is that after the structure one can allocate a number of the array elements and address them easily. Another option would be placing pointer in the samsung_usb2_phy_instance and allocate memory separately, but this would involve two allocations and a pointer would be always present in the structure. Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 0/9] phy: Add new Exynos USB 2.0 PHY driver
Hi Kishon, I wanted to ask about your comments to this patchset. As I mentioned there are two alternative version where the Exynos 4210 and 4212 support is merged in one file. I would be grateful if you had some time to look at the patchset and share your comments. Best wishes and happy new year! -- Kamil Debski Samsung RD Institute Poland From: Kamil Debski [mailto:k.deb...@samsung.com] Sent: Friday, December 20, 2013 2:24 PM Hi, This is the fifth version of the patchset. It adds a new Exynos USB 2.0 PHY driver. The driver uses the Generic PHY Framework. I would like to thank everyone who contributed with comments and took the time to read through the patches in the previous versions of this patchset. We had a lengthy discussion with Kishon about how the driver should look like. This patchset contains the updated version of my original idea, where support for Exynos 4210 and 4212 is done in separate files. Kishon's idea is to join these two into a single file. I have prepared two alternative version which I will send soon after this patchset. Just like the fourth version this patch depends on: [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi files [1]. Best wishes, Kamil Debski [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html 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 instead of (1 x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray whitespace - move of_phy_provider_register() to the end of probe - add a regular error return code to the rate_to_clk functions - cleanup code and remove unused code - change struct names to avoid collisions - add mechanism to support multiple phys by the ehci driver Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove empty line that was wrongfully added) - fixes in the main driver - remove cpu_type in favour for a boolean flag matched with the compatible value - rename files, structures, variables and Kconfig entires - change from simple uphy to usb2_phy - fix multiline comments style - simplify #ifdefs in of_device_id - fix Kconfig description - change dev_info to dev_dbg where reasonable - cosmetic changes (remove wrongful blank lines) - remove unnecessary reference counting Changes from v1: - the changes include minor fixes of the hardware initialization of the PHY module - some other minor fixes were introduced -- Original cover letter: Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I
RE: [PATCH v5 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Hi Vivek, From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] Sent: Thursday, December 26, 2013 11:14 AM Hi Kamil, On Fri, Dec 20, 2013 at 6:54 PM, Kamil Debski k.deb...@samsung.com wrote: Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Commit title: s/ehci-s5p/ehci-exynos Thank you for spotting this. --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 35 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 98 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt index fa18612..413f7cd 100644 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt @@ -14,6 +14,10 @@ If controller implementation operates with big endian descriptors, If both big endian registers and descriptors are used by the controller implementation, big-endian property can be specified instead of having both big-endian-regs and big-endian- desc. + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a +consecutive number. Also it should contain phys and phy-names entries +specifying the phy used by the port. Example (Sequoia 440EPx): ehci@e300 { @@ -23,3 +27,34 @@ Example (Sequoia 440EPx): reg = 0 e300 90 0 e390 70; big-endian; }; + +Example (Exynos 4212): +ehci@1258 { +compatible = samsung,exynos4210-ehci; +reg = 0x1258 0x2; +interrupts = 0 70 0; +clocks = clock 304, clock 305; +clock-names = usbhost, otg; +status = disabled; +#address-cells = 1; +#size-cells = 0; +port@0 { +reg = 0; +phys = usb2phy 1; +phy-names = host; +status = disabled; +}; +port@1 { +reg = 1; +phys = usb2phy 2; +phy-names = hsic0; +status = disabled; +}; +port@2 { +reg = 2; +phys = usb2phy 3; +phy-names = hsic1; +status = disabled; +}; +}; Should we place above documentation in Documentation/devicetree/bindings/usb/exynos-usb.txt ? or is it something that i am missing. Indeed, this should go to exynos-usb.txt instead of usb-ehci.txt. Thanks! + diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index d1d8c47..7c35501 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include linux/module.h #include linux/of.h #include linux/of_gpio.h +#include linux/phy/phy.h #include linux/platform_device.h #include linux/usb/phy.h #include linux/usb/samsung_usb_phy.h #include linux/usb.h #include linux/usb/hcd.h -#include linux/usb/otg.h #include ehci.h @@ -42,10 +42,10 @@ static const char hcd_name[] = ehci-exynos; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, can't request ehci vbus gpio %d, gpio); } +static int exynos_phys_on(struct phy *p[]) { + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i 0; i--) + if (p[i]) + phy_power_off(p[i]); So we are turning off, say, port0 phy in case port1 phy power_on fails; can't we still leave a usb2.0 phy(a normal host phy) 'on' in case the HSIC phy fails ? Currently all phys are can be either switched on or off. So if powering on one phy fails (and exynos_phy_on returns an error code), I would expect that no phy is switched on. I think that doing otherwise could leave the phys in strange state - some phys are on, some are off and the power_on call returned an error. + + return ret; +} + +static int exynos_phys_off(struct phy *p[]) { + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_off(p[i]); + + return ret
RE: [PATCH v2 9/9] dts: Add usb2phy to Exynos 5250
Hi, From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] Sent: Thursday, December 26, 2013 11:32 AM Hi Kamil, On Fri, Dec 20, 2013 at 6:54 PM, Kamil Debski k.deb...@samsung.com wrote: Add support to PHY of USB2 of the Exynos 5250 SoC. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos5250.dtsi | 33 --- drivers/phy/phy-exynos5250-usb2.c | 64 + 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 2f264ad..922e0ed 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -163,6 +163,11 @@ interrupts = 0 47 0; }; + sys_syscon: syscon@1004 { + compatible = samsung,exynos5250-sys, syscon; + reg = 0x1005 0x5000; + }; + pmu_syscon: syscon@1004 { compatible = samsung,exynos5250-pmu, syscon; reg = 0x1004 0x5000; @@ -505,6 +510,14 @@ clocks = clock 285; clock-names = usbhost; + #address-cells = 1; + #size-cells = 0; + port@0 { + reg = 0; + phys = usb2_phy 1; + phy-names = host; + status = ok; + }; }; usb@1212 { @@ -516,19 +529,15 @@ clock-names = usbhost; }; - usb2_phy: usbphy@1213 { - compatible = samsung,exynos5250-usb2phy; + usb2_phy: phy@1213 { + compatible = samsung,exynos5250-usb2-phy; reg = 0x1213 0x100; - clocks = clock 1, clock 285; - clock-names = ext_xtal, usbhost; - #address-cells = 1; - #size-cells = 1; - ranges; - - usbphy-sys { - reg = 0x10040704 0x8, - 0x10050230 0x4; - }; + clocks = clock 285, clock 1, clock 1, clock 1, + clock 1; + clock-names = phy, device, host, hsic0, hsic1; + #phy-cells = 1; + samsung,sysreg-phandle = sys_syscon; + samsung,pmureg-phandle = pmu_syscon; }; amba { diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c index b9b3b98..337bf82 100644 --- a/drivers/phy/phy-exynos5250-usb2.c +++ b/drivers/phy/phy-exynos5250-usb2.c Separate patches for dt and driver ? I think you wanted to move these changes to : [PATCH v5 7/9] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver Good point. I am planning to reorganise this patchset to prevent breaking git bisect. I wanted to wait for more comments to this version, so I could address any issues that may be reported. @@ -58,7 +58,13 @@ #define EXYNOS_5250_HOSTPHYCTRL2 0x20 Shouldn't we leave the naming as EXYNOS_5250_HSICPHYCTRL2 instead of EXYNOS_5250_HOSTPHYCTRL2 ? That will go in sync with the user-manual too. and similar for EXYNOS_5250_HOSTPHYCTRL1 and below bit definitions too ? Thank you for pointing this out. #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_MASK(0x3 23) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT (0x2 23) #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_MASK(0x7f 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12 (0x24 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_15 (0x1c 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_16 (0x1a 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_19_2(0x15 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_20 (0x14 16) #define EXYNOS_5250_HOSTPHYCTRLX_SIDDQ BIT(6) #define EXYNOS_5250_HOSTPHYCTRLX_FORCESLEEPBIT(5) #define EXYNOS_5250_HOSTPHYCTRLX_FORCESUSPEND BIT(4) @@ -191,13 +197,14 @@ static void exynos5250_isol(struct samsung_usb2_phy_instance *inst, bool on) regmap_update_bits(drv-reg_pmu, offset, mask, on ? 0 : mask); } -static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) +static int exynos5250_power_on(struct samsung_usb2_phy_instance +*inst) void ? we really don't have much to return in this function. Initially the idea was to enable the return of an error code. However, I see that for all currently supported SoCs the ops always returns 0. So I will consider switching to void. { struct samsung_usb2_phy_driver *drv = inst-drv; u32 ctrl0; u32 otg; u32 ehci; u32 ohci; + u32 hsic; switch (inst-cfg-id) { case
[PATCH v5 0/9] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the fifth version of the patchset. It adds a new Exynos USB 2.0 PHY driver. The driver uses the Generic PHY Framework. I would like to thank everyone who contributed with comments and took the time to read through the patches in the previous versions of this patchset. We had a lengthy discussion with Kishon about how the driver should look like. This patchset contains the updated version of my original idea, where support for Exynos 4210 and 4212 is done in separate files. Kishon's idea is to join these two into a single file. I have prepared two alternative version which I will send soon after this patchset. Just like the fourth version this patch depends on: [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi files [1]. Best wishes, Kamil Debski [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html 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 instead of (1 x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray whitespace - move of_phy_provider_register() to the end of probe - add a regular error return code to the rate_to_clk functions - cleanup code and remove unused code - change struct names to avoid collisions - add mechanism to support multiple phys by the ehci driver Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove empty line that was wrongfully added) - fixes in the main driver - remove cpu_type in favour for a boolean flag matched with the compatible value - rename files, structures, variables and Kconfig entires - change from simple uphy to usb2_phy - fix multiline comments style - simplify #ifdefs in of_device_id - fix Kconfig description - change dev_info to dev_dbg where reasonable - cosmetic changes (remove wrongful blank lines) - remove unnecessary reference counting Changes from v1: - the changes include minor fixes of the hardware initialization of the PHY module - some other minor fixes were introduced -- Original cover letter: Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the near future. I welcome your comments. -- [1] https://lkml.org/lkml/2013/8/21/29 Kamil Debski (8): phy: core: Add an exported of_phy_get function phy: core: Add devm_of_phy_get to phy-core phy: Add new Exynos USB PHY driver usb: ehci-s5p: Change to use phy provided by the generic phy framework usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
[PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support
This the alternative version of the support for Exynos 421x USB 2.0 PHY in the Generic PHY framework. In this version the support for Exynos 4210 and 4212 was joined into one file. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Hi, Me and Kishon were discussing for quite a long time the way how Exynos 4 should be handled. I have decided to post the original patches and try to make an alternative version with support for Exynos 4210 and 4212 joined in one file. I have prepared two versions. The first one has 506 lines (vs 563 when two files are used). When doing the second version I was a little more aggresive in removing code. This was done at a cost of adding if's deciding which SoC version the driver is dealing with in some internal functions. This resulted in a better number of removed lines - the second version has only 452 lines (vs 563 original and 506 version 1). Personally I like the original approach. One of my goals was to create a driver that would be clear and easy to understand. I see that this was done at a cost of having the code a little longer. The first alternative version mostly was done by removing duplicate defines of register values. The code clarity suffers a bit, but is still acceptable in my opinion. As to the second alternative version. It has the fewest lines, but I am not an enthusiast of using if this is SoC in functions. Anyway - please have a look at these two alternative versions in addition to looking at the original patch phy: Add new Exynos USB PHY driver. Best wishes, Kamil Debski --- drivers/phy/phy-exynos4212-usb2.c | 506 + 1 file changed, 506 insertions(+) create mode 100644 drivers/phy/phy-exynos4212-usb2.c diff --git a/drivers/phy/phy-exynos4212-usb2.c b/drivers/phy/phy-exynos4212-usb2.c new file mode 100644 index 000..3fa22d0 --- /dev/null +++ b/drivers/phy/phy-exynos4212-usb2.c @@ -0,0 +1,506 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 and 4212 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 */ + +/* PHY power control */ +#define EXYNOS_421x_UPHYPWR0x0 + +#define EXYNOS_421x_UPHYPWR_PHY0_SUSPEND BIT(0) +#define EXYNOS_421x_UPHYPWR_PHY0_PWR BIT(3) +#define EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR BIT(4) +#define EXYNOS_421x_UPHYPWR_PHY0_SLEEP BIT(5) +#define EXYNOS_421x_UPHYPWR_PHY0 ( \ + EXYNOS_421x_UPHYPWR_PHY0_SUSPEND | \ + EXYNOS_421x_UPHYPWR_PHY0_PWR | \ + EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR | \ + EXYNOS_421x_UPHYPWR_PHY0_SLEEP) + +#define EXYNOS_421x_UPHYPWR_PHY1_SUSPEND BIT(6) +#define EXYNOS_421x_UPHYPWR_PHY1_PWR BIT(7) +#define EXYNOS_421x_UPHYPWR_PHY1_SLEEP BIT(8) +#define EXYNOS_421x_UPHYPWR_PHY1 ( \ + EXYNOS_421x_UPHYPWR_PHY1_SUSPEND | \ + EXYNOS_421x_UPHYPWR_PHY1_PWR | \ + EXYNOS_421x_UPHYPWR_PHY1_SLEEP) + +#define EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND BIT(9) +#define EXYNOS_4210_UPHYPWR_HSCI0_SLEEPBIT(10) +#define EXYNOS_4210_UPHYPWR_HSCI0 ( \ + EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND | \ + EXYNOS_4210_UPHYPWR_HSCI0_SLEEP) + +#define EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND BIT(11) +#define EXYNOS_4210_UPHYPWR_HSCI1_SLEEPBIT(12) +#define EXYNOS_4210_UPHYPWR_HSCI1 ( \ + EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND | \ + EXYNOS_4210_UPHYPWR_HSCI1_SLEEP) + +#define EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND BIT(9) +#define EXYNOS_4212_UPHYPWR_HSCI0_PWR BIT(10) +#define EXYNOS_4212_UPHYPWR_HSCI0_SLEEPBIT(11) +#define EXYNOS_4212_UPHYPWR_HSCI0 ( \ + EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND | \ + EXYNOS_4212_UPHYPWR_HSCI0_PWR | \ + EXYNOS_4212_UPHYPWR_HSCI0_SLEEP) + +#define EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND BIT(12) +#define EXYNOS_4212_UPHYPWR_HSCI1_PWR BIT(13) +#define EXYNOS_4212_UPHYPWR_HSCI1_SLEEPBIT(14) +#define EXYNOS_4212_UPHYPWR_HSCI1 ( \ + EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND | \ + EXYNOS_4212_UPHYPWR_HSCI1_PWR | \ + EXYNOS_4212_UPHYPWR_HSCI1_SLEEP) + +/* PHY clock control */ +#define EXYNOS_421x_UPHYCLK0x4 + +#define EXYNOS_421x_UPHYCLK_PHY0_COMMON_ON BIT(4) +#define EXYNOS_421x_UPHYCLK_PHY1_COMMON_ON BIT(7) + +#define EXYNOS_4210_UPHYCLK_PHYFSEL_MASK (0x3 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_48MHZ (0x0 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_24MHZ (0x3 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_12MHZ (0x2 0) + +#define EXYNOS_4210_UPHYCLK_PHY0_ID_PULLUP BIT(2) + +#define
[PATCH v2 9/9] dts: Add usb2phy to Exynos 5250
Add support to PHY of USB2 of the Exynos 5250 SoC. Signed-off-by: Kamil Debski k.deb...@samsung.com --- arch/arm/boot/dts/exynos5250.dtsi | 33 --- drivers/phy/phy-exynos5250-usb2.c | 64 + 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 2f264ad..922e0ed 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -163,6 +163,11 @@ interrupts = 0 47 0; }; + sys_syscon: syscon@1004 { + compatible = samsung,exynos5250-sys, syscon; + reg = 0x1005 0x5000; + }; + pmu_syscon: syscon@1004 { compatible = samsung,exynos5250-pmu, syscon; reg = 0x1004 0x5000; @@ -505,6 +510,14 @@ clocks = clock 285; clock-names = usbhost; + #address-cells = 1; + #size-cells = 0; + port@0 { + reg = 0; + phys = usb2_phy 1; + phy-names = host; + status = ok; + }; }; usb@1212 { @@ -516,19 +529,15 @@ clock-names = usbhost; }; - usb2_phy: usbphy@1213 { - compatible = samsung,exynos5250-usb2phy; + usb2_phy: phy@1213 { + compatible = samsung,exynos5250-usb2-phy; reg = 0x1213 0x100; - clocks = clock 1, clock 285; - clock-names = ext_xtal, usbhost; - #address-cells = 1; - #size-cells = 1; - ranges; - - usbphy-sys { - reg = 0x10040704 0x8, - 0x10050230 0x4; - }; + clocks = clock 285, clock 1, clock 1, clock 1, + clock 1; + clock-names = phy, device, host, hsic0, hsic1; + #phy-cells = 1; + samsung,sysreg-phandle = sys_syscon; + samsung,pmureg-phandle = pmu_syscon; }; amba { diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c index b9b3b98..337bf82 100644 --- a/drivers/phy/phy-exynos5250-usb2.c +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -58,7 +58,13 @@ #define EXYNOS_5250_HOSTPHYCTRL2 0x20 #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_MASK(0x3 23) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT (0x2 23) #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_MASK(0x7f 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12 (0x24 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_15 (0x1c 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_16 (0x1a 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_19_2(0x15 16) +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_20 (0x14 16) #define EXYNOS_5250_HOSTPHYCTRLX_SIDDQ BIT(6) #define EXYNOS_5250_HOSTPHYCTRLX_FORCESLEEPBIT(5) #define EXYNOS_5250_HOSTPHYCTRLX_FORCESUSPEND BIT(4) @@ -191,13 +197,14 @@ static void exynos5250_isol(struct samsung_usb2_phy_instance *inst, bool on) regmap_update_bits(drv-reg_pmu, offset, mask, on ? 0 : mask); } -static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) +static int exynos5250_power_on(struct samsung_usb2_phy_instance *inst) { struct samsung_usb2_phy_driver *drv = inst-drv; u32 ctrl0; u32 otg; u32 ehci; u32 ohci; + u32 hsic; switch (inst-cfg-id) { case EXYNOS5250_DEVICE: @@ -234,6 +241,8 @@ static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) break; case EXYNOS5250_HOST: + case EXYNOS5250_HSIC0: + case EXYNOS5250_HSIC1: /* Host registers configuration */ ctrl0 = readl(drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL0); /* The clock */ @@ -279,6 +288,18 @@ static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) EXYNOS_5250_USBOTGSYS_LINK_SW_RST_UOTG | EXYNOS_5250_USBOTGSYS_PHYLINK_SW_RESET); + /* HSIC phy configuration */ + hsic = (EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12 | + EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT | + EXYNOS_5250_HOSTPHYCTRLX_PHYSWRST); + writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL1); + writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL2); + udelay(10); + hsic = ~EXYNOS_5250_HOSTPHYCTRLX_PHYSWRST; + writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL1); + writel
[PATCH RFC alternative ver 2] phy: Exynos 421x USB 2.0 PHY support
This the alternative version of the support for Exynos 421x USB 2.0 PHY in the Generic PHY framework. In this version the support for Exynos 4210 and 4212 was joined into one file. Signed-off-by: Kamil Debski k.deb...@samsung.com --- Hi, This is the second alternative version. Please look at [PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support for detailed description. Best wishes, Kamil Debski --- drivers/phy/phy-exynos4212-usb2.c | 452 + drivers/phy/phy-samsung-usb2.h|1 + 2 files changed, 453 insertions(+) create mode 100644 drivers/phy/phy-exynos4212-usb2.c diff --git a/drivers/phy/phy-exynos4212-usb2.c b/drivers/phy/phy-exynos4212-usb2.c new file mode 100644 index 000..8f7578a --- /dev/null +++ b/drivers/phy/phy-exynos4212-usb2.c @@ -0,0 +1,452 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 and 4212 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 */ + +/* PHY power control */ +#define EXYNOS_421x_UPHYPWR0x0 + +#define EXYNOS_421x_UPHYPWR_PHY0_SUSPEND BIT(0) +#define EXYNOS_421x_UPHYPWR_PHY0_PWR BIT(3) +#define EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR BIT(4) +#define EXYNOS_421x_UPHYPWR_PHY0_SLEEP BIT(5) +#define EXYNOS_421x_UPHYPWR_PHY0 ( \ + EXYNOS_421x_UPHYPWR_PHY0_SUSPEND | \ + EXYNOS_421x_UPHYPWR_PHY0_PWR | \ + EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR | \ + EXYNOS_421x_UPHYPWR_PHY0_SLEEP) + +#define EXYNOS_421x_UPHYPWR_PHY1_SUSPEND BIT(6) +#define EXYNOS_421x_UPHYPWR_PHY1_PWR BIT(7) +#define EXYNOS_421x_UPHYPWR_PHY1_SLEEP BIT(8) +#define EXYNOS_421x_UPHYPWR_PHY1 ( \ + EXYNOS_421x_UPHYPWR_PHY1_SUSPEND | \ + EXYNOS_421x_UPHYPWR_PHY1_PWR | \ + EXYNOS_421x_UPHYPWR_PHY1_SLEEP) + +#define EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND BIT(9) +#define EXYNOS_4210_UPHYPWR_HSCI0_SLEEPBIT(10) +#define EXYNOS_4210_UPHYPWR_HSCI0 ( \ + EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND | \ + EXYNOS_4210_UPHYPWR_HSCI0_SLEEP) + +#define EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND BIT(11) +#define EXYNOS_4210_UPHYPWR_HSCI1_SLEEPBIT(12) +#define EXYNOS_4210_UPHYPWR_HSCI1 ( \ + EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND | \ + EXYNOS_4210_UPHYPWR_HSCI1_SLEEP) + +#define EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND BIT(9) +#define EXYNOS_4212_UPHYPWR_HSCI0_PWR BIT(10) +#define EXYNOS_4212_UPHYPWR_HSCI0_SLEEPBIT(11) +#define EXYNOS_4212_UPHYPWR_HSCI0 ( \ + EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND | \ + EXYNOS_4212_UPHYPWR_HSCI0_PWR | \ + EXYNOS_4212_UPHYPWR_HSCI0_SLEEP) + +#define EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND BIT(12) +#define EXYNOS_4212_UPHYPWR_HSCI1_PWR BIT(13) +#define EXYNOS_4212_UPHYPWR_HSCI1_SLEEPBIT(14) +#define EXYNOS_4212_UPHYPWR_HSCI1 ( \ + EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND | \ + EXYNOS_4212_UPHYPWR_HSCI1_PWR | \ + EXYNOS_4212_UPHYPWR_HSCI1_SLEEP) + +/* PHY clock control */ +#define EXYNOS_421x_UPHYCLK0x4 + +#define EXYNOS_421x_UPHYCLK_PHY0_COMMON_ON BIT(4) +#define EXYNOS_421x_UPHYCLK_PHY1_COMMON_ON BIT(7) + +#define EXYNOS_4210_UPHYCLK_PHYFSEL_MASK (0x3 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_48MHZ (0x0 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_24MHZ (0x3 0) +#define EXYNOS_4210_UPHYCLK_PHYFSEL_12MHZ (0x2 0) + +#define EXYNOS_4210_UPHYCLK_PHY0_ID_PULLUP BIT(2) + +#define EXYNOS_4212_UPHYCLK_PHYFSEL_MASK (0x7 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_9MHZ6 (0x0 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_10MHZ (0x1 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_12MHZ (0x2 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_19MHZ2 (0x3 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_20MHZ (0x4 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_24MHZ (0x5 0) +#define EXYNOS_4212_UPHYCLK_PHYFSEL_50MHZ (0x7 0) + +#define EXYNOS_4212_UPHYCLK_PHY0_ID_PULLUP BIT(3) + +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_MASK (0x7f 10) +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_12MHZ (0x24 10) +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_15MHZ (0x1c 10) +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_16MHZ (0x1a 10) +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_19MHZ2 (0x15 10) +#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_20MHZ (0x14 10) + +/* PHY reset control */ +#define EXYNOS_421x_UPHYRST0x8 + +#define EXYNOS_421x_URSTCON_PHY0 BIT(0) +#define EXYNOS_421x_URSTCON_OTG_HLINK BIT(1) +#define EXYNOS_421x_URSTCON_OTG_PHYLINKBIT
[PATCH v2 8/9] dts: Add usb2phy to Exynos 4
Add support to PHY of USB2 of the Exynos 4 SoC. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/arm/samsung/pmu.txt|2 ++ arch/arm/boot/dts/exynos4.dtsi | 31 arch/arm/boot/dts/exynos4210.dtsi | 17 +++ arch/arm/boot/dts/exynos4x12.dtsi | 17 +++ 4 files changed, 67 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt b/Documentation/devicetree/bindings/arm/samsung/pmu.txt index 307e727..bfccab0 100644 --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers Properties: - name : should be 'syscon'; - compatible : should contain two values. First value must be one from following list: + - samsung,exynos4210-pmu - for Exynos4210 SoC, + - samsung,exynos4212-pmu - for Exynos4212 SoC, - samsung,exynos5250-pmu - for Exynos5250 SoC, - samsung,exynos5420-pmu - for Exynos5420 SoC. second value must be always syscon. diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index a73eeb5..031d07a 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -253,6 +253,17 @@ status = disabled; }; + usbotg@1248 { + compatible = samsung,s3c6400-hsotg; + reg = 0x1248 0x2; + interrupts = 0 71 0; + clocks = clock 305; + clock-names = otg; + phys = usb2phy 0; + phy-names = usb2-phy; + status = disabled; + }; + ehci@1258 { compatible = samsung,exynos4210-ehci; reg = 0x1258 0x100; @@ -260,6 +271,26 @@ clocks = clock 304; clock-names = usbhost; status = disabled; + #address-cells = 1; + #size-cells = 0; + port@0 { + phys = usb2phy 1; + phy-names = host; + reg = 0; + status = disabled; + }; + port@1 { + phys = usb2phy 2; + phy-names = hsic0; + reg = 1; + status = disabled; + }; + port@2 { + phys = usb2phy 3; + phy-names = hsic1; + reg = 2; + status = disabled; + }; }; ohci@1259 { diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi index 057d682..f9d06bb 100644 --- a/arch/arm/boot/dts/exynos4210.dtsi +++ b/arch/arm/boot/dts/exynos4210.dtsi @@ -155,4 +155,21 @@ samsung,lcd-wb; }; }; + + pmu_reg: syscon@1002 { + compatible = samsung,exynos4210-pmu, syscon; + reg = 0x1002 0x4000; + }; + + usb2phy: phy@125B { + compatible = samsung,exynos4210-usb2-phy; + reg = 0x125B 0x100; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + status = disabled; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; + }; }; diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi index ad531fe..712 100644 --- a/arch/arm/boot/dts/exynos4x12.dtsi +++ b/arch/arm/boot/dts/exynos4x12.dtsi @@ -176,4 +176,21 @@ }; }; }; + + pmu_reg: syscon@1002 { + compatible = samsung,exynos4212-pmu, syscon; + reg = 0x1002 0x4000; + }; + + usb2phy: phy@125B { + compatible = samsung,exynos4212-usb2-phy; + reg = 0x125B 0x100; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + status = disabled; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; + }; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 35 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 98 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt index fa18612..413f7cd 100644 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt @@ -14,6 +14,10 @@ If controller implementation operates with big endian descriptors, If both big endian registers and descriptors are used by the controller implementation, big-endian property can be specified instead of having both big-endian-regs and big-endian-desc. + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Example (Sequoia 440EPx): ehci@e300 { @@ -23,3 +27,34 @@ Example (Sequoia 440EPx): reg = 0 e300 90 0 e390 70; big-endian; }; + +Example (Exynos 4212): +ehci@1258 { +compatible = samsung,exynos4210-ehci; +reg = 0x1258 0x2; +interrupts = 0 70 0; +clocks = clock 304, clock 305; +clock-names = usbhost, otg; +status = disabled; +#address-cells = 1; +#size-cells = 0; +port@0 { +reg = 0; +phys = usb2phy 1; +phy-names = host; +status = disabled; +}; +port@1 { +reg = 1; +phys = usb2phy 2; +phy-names = hsic0; +status = disabled; +}; +port@2 { +reg = 2; +phys = usb2phy 3; +phy-names = hsic1; +status = disabled; +}; +}; + diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index d1d8c47..7c35501 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include linux/module.h #include linux/of.h #include linux/of_gpio.h +#include linux/phy/phy.h #include linux/platform_device.h #include linux/usb/phy.h #include linux/usb/samsung_usb_phy.h #include linux/usb.h #include linux/usb/hcd.h -#include linux/usb/otg.h #include ehci.h @@ -42,10 +42,10 @@ static const char hcd_name[] = ehci-exynos; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, can't request ehci vbus gpio %d, gpio); } +static int exynos_phys_on(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i 0; i--) + if (p[i]) + phy_power_off(p[i]); + + return ret; +} + +static int exynos_phys_off(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 i PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_off(p[i]); + + return ret; +} + static int exynos_ehci_probe(struct platform_device *pdev) { struct exynos_ehci_hcd *exynos_ehci; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + struct phy *phy; + struct device_node *child; + int phy_number; int irq; int err; @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev) samsung,exynos5440-ehci)) goto skip_phy; - phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(pdev-dev, no platform data or transceiver defined\n); - return -EPROBE_DEFER; - } else { - exynos_ehci-phy = phy; - exynos_ehci-otg = phy-otg; + for_each_available_child_of_node(pdev-dev.of_node, child) { + err = of_property_read_u32(child, reg, phy_number); + if (err) { + dev_err(pdev-dev, Failed to parse device tree\n); + of_node_put(child); + return err
[PATCH v5 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Change the used phy driver to the new Exynos USB phy driver that uses the generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/usb/samsung-hsotg.txt |4 drivers/usb/gadget/s3c-hsotg.c | 11 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt index b83d428..75edb9d 100644 --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt @@ -24,6 +24,8 @@ Required properties: - first entry: must be otg - vusb_d-supply: phandle to voltage regulator of digital section, - vusb_a-supply: phandle to voltage regulator of analog section. +- phys: from general PHY binding: phandle to the PHY device +- phy-names: from general PHY binding: should be usb2-phy Example - @@ -36,5 +38,7 @@ Example clock-names = otg; vusb_d-supply = vusb_reg; vusb_a-supply = vusbdac_reg; + phys = usb2phy 0; + phy-names = usb2-phy; }; diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7aedaaf..a05c2f9 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -31,6 +31,7 @@ #include linux/regulator/consumer.h #include linux/of.h #include linux/of_platform.h +#include linux/phy/phy.h #include linux/usb/ch9.h #include linux/usb/gadget.h @@ -162,7 +163,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device*dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; struct s3c_hsotg_plat*plat; spinlock_t lock; @@ -2910,7 +2911,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg-dev, pdev 0x%p\n, pdev); if (hsotg-phy) - usb_phy_init(hsotg-phy); + phy_power_on(hsotg-phy); else if (hsotg-plat-phy_init) hsotg-plat-phy_init(pdev, hsotg-plat-phy_type); } @@ -2927,7 +2928,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg-dev); if (hsotg-phy) - usb_phy_shutdown(hsotg-phy); + phy_power_off(hsotg-phy); else if (hsotg-plat-phy_exit) hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type); } @@ -3534,7 +3535,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev); - struct usb_phy *phy; + struct phy *phy; struct device *dev = pdev-dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3549,7 +3550,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + phy = devm_phy_get(pdev-dev, usb2-phy); if (IS_ERR(phy)) { /* Fallback for pdata */ plat = dev_get_platdata(pdev-dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 3/9] 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 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 55 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 257 drivers/phy/phy-exynos4212-usb2.c | 306 drivers/phy/phy-samsung-usb2.c | 226 +++ drivers/phy/phy-samsung-usb2.h | 67 + 7 files changed, 943 insertions(+) create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-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..39d52cc 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,58 @@ 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,exynos4212-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 clocks is required by the phy module + - next for each of the phys a clock has to be assigned, this clock + will be used to determine clocking frequency for the phys + (the labels are specified in the paragraph below) + +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,exynos4212-usb2-phy; + reg = 0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4; + clocks = clock 305, clock 2, clock 2, clock 2, + clock 2; + clock-names = phy, device, host, hsic0, hsic1; + 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/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..8e5cce1 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -51,4 +51,33 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config PHY_SAMSUNG_USB2 + tristate Samsung USB 2.0 PHY driver + select GENERIC_PHY + select MFD_SYSCON + help + Enable this to support the Samsung USB 2.0 PHY driver for Samsung + SoCs. This driver provides the interface for USB 2.0 PHY. Support for + particular SoCs has to be enabled in addition to this driver. Number + and type of supported phys depends on the SoC. + +config PHY_EXYNOS4210_USB2 + bool Support for Exynos 4210 + depends on PHY_SAMSUNG_USB2 + depends on CPU_EXYNOS4210 + help + Enable USB PHY support for Exynos 4210. 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 4210 four + phys are available - device, host, HSCI0 and HSCI1. + +config PHY_EXYNOS4212_USB2 + bool Support for Exynos 4212 + depends on PHY_SAMSUNG_USB2 + depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) + help + Enable USB PHY support for Exynos 4212. This option requires that + Samsung USB 2.0 PHY driver is enabled and means
[PATCH v4 2/9] 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 |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index d6f8c34..0551cc3 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -450,6 +450,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_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 bcb6274..864914c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 7/9] 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 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 356 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 376 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 eb40460..afc47c2 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -29,6 +29,7 @@ Required properties: - samsung,s5pv210-usb2-phy - samsung,exynos4210-usb2-phy - samsung,exynos4212-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 b2c51ce..726410f 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -90,4 +90,15 @@ config PHY_EXYNOS4212_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 4212 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 fefc6c2..33c3ac1 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= phy-samsung-usb2.o obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4212_USB2) += phy-exynos4212-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..b9b3b98 --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,356 @@ +/* + * 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
[PATCH v5 6/9] phy: Add support for S5PV210 to the Exynos USB 2.0 PHY driver
From: Mateusz Krawczuk mat.krawc...@gmail.com Add support for the Samsung's S5PV210 SoC to the Exynos USB 2.0 PHY driver. Signed-off-by: Mateusz Krawczuk m.krawc...@partner.samsung.com [k.deb...@samsung.com: cleanup and commit description] [k.deb...@samsung.com: make changes accordingly to the mailing list comments] Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 10 + drivers/phy/Makefile |1 + drivers/phy/phy-s5pv210-usb2.c | 199 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 218 insertions(+) create mode 100644 drivers/phy/phy-s5pv210-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 39d52cc..eb40460 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -26,6 +26,7 @@ Samsung S5P/EXYNOS SoC series USB PHY Required properties: - compatible : should be one of the listed compatibles: + - samsung,s5pv210-usb2-phy - samsung,exynos4210-usb2-phy - samsung,exynos4212-usb2-phy - reg : a list of registers used by phy driver diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 8e5cce1..b2c51ce 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -61,6 +61,16 @@ config PHY_SAMSUNG_USB2 particular SoCs has to be enabled in addition to this driver. Number and type of supported phys depends on the SoC. +config PHY_S5PV210_USB2 + bool Support for S5PV210 + depends on PHY_SAMSUNG_USB2 + depends on ARCH_S5PV210 + help + Enable USB PHY support for S5PV210. 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 S5PV210 two phys + are available - device and host. + config PHY_EXYNOS4210_USB2 bool Support for Exynos 4210 depends on PHY_SAMSUNG_USB2 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9f4befd..fefc6c2 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -8,5 +8,6 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o +obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4212_USB2) += phy-exynos4212-usb2.o diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c new file mode 100644 index 000..58797a7 --- /dev/null +++ b/drivers/phy/phy-s5pv210-usb2.c @@ -0,0 +1,199 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Authors: 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 phy-samsung-usb2.h + +/* Exynos USB PHY registers */ + +/* PHY power control */ +#define S5PV210_UPHYPWR0x0 + +#define S5PV210_UPHYPWR_PHY0_SUSPEND BIT(0) +#define S5PV210_UPHYPWR_PHY0_PWR BIT(3) +#define S5PV210_UPHYPWR_PHY0_OTG_PWR BIT(4) +#define S5PV210_UPHYPWR_PHY0 ( \ + S5PV210_UPHYPWR_PHY0_SUSPEND | \ + S5PV210_UPHYPWR_PHY0_PWR | \ + S5PV210_UPHYPWR_PHY0_OTG_PWR) + +#define S5PV210_UPHYPWR_PHY1_SUSPEND BIT(6) +#define S5PV210_UPHYPWR_PHY1_PWR BIT(7) +#define S5PV210_UPHYPWR_PHY1 ( \ + S5PV210_UPHYPWR_PHY1_SUSPEND | \ + S5PV210_UPHYPWR_PHY1_PWR) + +/* PHY clock control */ +#define S5PV210_UPHYCLK0x4 + +#define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 0) +#define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 0) +#define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 0) +#define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 0) + +#define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2) +#define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4) +#define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7) + +/* PHY reset control */ +#define S5PV210_UPHYRST0x8 + +#define S5PV210_URSTCON_PHY0 BIT(0) +#define S5PV210_URSTCON_OTG_HLINK BIT(1) +#define S5PV210_URSTCON_OTG_PHYLINKBIT(2) +#define S5PV210_URSTCON_PHY1_ALL BIT(3) +#define S5PV210_URSTCON_HOST_LINK_ALL BIT(4) + +/* Isolation, configured in the power management unit */ +#define S5PV210_USB_ISOL_DEVICE_OFFSET 0x704 +#define
[PATCH v4 1/9] 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 |1 + 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..d6f8c34 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -240,8 +240,8 @@ out: 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, @@ -250,20 +250,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); @@ -283,6 +280,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() * @@ -370,7 +397,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); if (IS_ERR(phy)) { dev_err(dev, unable to find phy\n); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..bcb6274 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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, -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Hi Matt, I am afraid it is not possible. This patch cannot go in without the new phy driver. It would break Exynos USB functionality. This is because it changes s3c-hsotg to use the new phy driver. I am working on an updated patch series addressing all the comments. time permitting I want to post an alternative version - integrating as much as possible in a single file. This way it would be possible to have a hands-on comparison of the two approaches we were discussing with Kishon. I estimate that I post it this week. Best wishes, -- Kamil Debski Samsung RD Institute Poland -Original Message- From: Matt Porter [mailto:mpor...@linaro.org] Sent: Monday, December 16, 2013 10:40 PM To: Kamil Debski Cc: linux-ker...@vger.kernel.org; linux-samsung-soc@vger.kernel.org; linux-...@vger.kernel.org; devicet...@vger.kernel.org; kyungmin.p...@samsung.com; kis...@ti.com; t.f...@samsung.com; s.nawro...@samsung.com; m.szyprow...@samsung.com; gautam.vi...@samsung.com; mat.krawc...@gmail.com; yulgon@samsung.com; p.pan...@samsung.com; av.tikhomi...@samsung.com; jg1@samsung.com; ga...@codeaurora.org; Felipe Balbi Subject: Re: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote: Change the used phy driver to the new Exynos USB phy driver that uses the generic phy framework. Signed-off-by: Kamil Debski k.deb...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/usb/samsung-hsotg.txt |4 drivers/usb/gadget/s3c-hsotg.c | 11 ++ - 2 files changed, 10 insertions(+), 5 deletions(-) Kamil, Can we separate this patch out of this series? My bcm281xx series is ready to go except for this dependency. Felipe has noted that there's only a week until he locks his tree down for 3.14 [1]. I'm willing to update this versus the comment Kishon made on fixing the example if you don't have time before then. Let me know. [1] https://lkml.org/lkml/2013/12/16/555 Thanks, Matt diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt index b83d428..9340d06 100644 --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt @@ -24,6 +24,8 @@ Required properties: - first entry: must be otg - vusb_d-supply: phandle to voltage regulator of digital section, - vusb_a-supply: phandle to voltage regulator of analog section. +- phys: from general PHY binding: phandle to the PHY device +- phy-names: from general PHY binding: should be usb2-phy Example - @@ -36,5 +38,7 @@ Example clock-names = otg; vusb_d-supply = vusb_reg; vusb_a-supply = vusbdac_reg; + phys = usb2phy 0; + phy-names = device; }; diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index eccb147..db096fd 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -31,6 +31,7 @@ #include linux/regulator/consumer.h #include linux/of.h #include linux/of_platform.h +#include linux/phy/phy.h #include linux/usb/ch9.h #include linux/usb/gadget.h @@ -162,7 +163,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device*dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; struct s3c_hsotg_plat*plat; spinlock_t lock; @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg-dev, pdev 0x%p\n, pdev); if (hsotg-phy) - usb_phy_init(hsotg-phy); + phy_power_on(hsotg-phy); else if (hsotg-plat-phy_init) hsotg-plat-phy_init(pdev, hsotg-plat-phy_type); } @@ - 2922,7 +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg-dev); if (hsotg-phy) - usb_phy_shutdown(hsotg-phy); + phy_power_off(hsotg-phy); else if (hsotg-plat-phy_exit) hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type); } @@ - 3529,7 +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev); - struct usb_phy *phy; + struct phy *phy; struct device *dev = pdev-dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3544,7 +3545,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + phy = devm_phy_get(pdev-dev, usb2-phy); if (IS_ERR(phy
RE: [PATCH v4 3/9] phy: Add new Exynos USB PHY driver
Hi Anton, From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com] Sent: Tuesday, December 10, 2013 3:43 AM Hi Kamil, Same USB2.0 PHY may be used by several HCDs, for example EHCI and OHCI. Consider the situation, when EHCI stops using the PHY and calls power_off, then OHCI becomes non-operational. In other words, PHY power_on and power_off calls must be balanced. Shall we handle it in your driver? (usage count?) Please look in the drivers/phy/phy-core.c file. Usage count is handled there - see phy_power_on and phy_power_off functions. I understand that after both EHCI and OHCI power on the phy, the usage count is 2. So powering off one of them (EHCI for instance) the usage count is still 1, so the OHCI should still work properly. [snip] Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/2] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying the device_node instead of by name. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 0107f71..d45ad87 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -450,6 +450,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_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 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 bcb6274..864914c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH RESEND v2 1/2] phy: core: Add an exported of_phy_get function
Hi, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, December 16, 2013 10:01 AM On Friday 13 December 2013 08:56 PM, Kamil Debski wrote: Hi Kishon, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Friday, December 13, 2013 3:45 PM Hi, On Friday 13 December 2013 07:32 PM, Kamil Debski wrote: 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 --- It seems that my git send-email is playing up and sent the previous emails without from. This is a resend. Sorry for any confusion. --- drivers/phy/phy-core.c | 41 --- -- include/linux/phy/phy.h |1 + 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..f0dbd42 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -240,8 +240,8 @@ out: 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, @@ -250,20 +250,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); @@ -283,6 +280,32 @@ 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 + * @index: the index of the phy Would be better if the user can get the PHY by string instead of index. Ok, this sounds doable. I will add of_phy_get_by_name analogous to the clk framework. Nope. It was decided initially to have minimal no of APIs exported to get PHYs. So you can just get string as argument instead of index and leave the name of the API to just of_phy_get. If you say so. I just sent a new version taking a string id instead of an index. I hope you find it satisfying. Thanks Kishon + * + * 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, int index) { + struct phy *phy = NULL; + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) dev_err here? dev_err requires a dev, so it is not possible with the arguments used. And we do not want to add any extra parameters to keep the function call analogous to other of_*_get (as for example of_clk_get). Best wishes, Best wishes, -- Kamil Debski Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RESEND v2 1/2] 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 --- It seems that my git send-email is playing up and sent the previous emails without from. This is a resend. Sorry for any confusion. --- drivers/phy/phy-core.c | 41 - include/linux/phy/phy.h |1 + 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..f0dbd42 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -240,8 +240,8 @@ out: 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, @@ -250,20 +250,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); @@ -283,6 +280,32 @@ 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 + * @index: the index of the phy + * + * 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, int index) +{ + struct phy *phy = NULL; + + 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() * @@ -370,7 +393,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); if (IS_ERR(phy)) { dev_err(dev, unable to find phy\n); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..169f572 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_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, int index); 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, -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying the device_node instead of by name. Signed-off-by: Kamil Debski k.deb...@samsung.com --- It seems that my git send-email is playing up and sent the previous emails without from. This is a resend. Sorry for any confusion. --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index f0dbd42..661f7ab 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -446,6 +446,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @index: the index of the phy + * + * Gets the phy using 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, + int index) +{ + 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, index); + 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 169f572..db36d81 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + int index); 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, int index); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html