From: Peter Chen <peter.chen@freescale.com>
To: Stefan Agner <stefan@agner.ch>
Cc: Sanchayan Maity <maitysanchayan@gmail.com>,
<gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] usb: chipidea: Add identification registers access APIs
Date: Thu, 25 Dec 2014 10:03:02 +0800 [thread overview]
Message-ID: <20141225020259.GA5077@shlinux2> (raw)
In-Reply-To: <4f5efe169ed3ab16ffcbee52dd6b7661@agner.ch>
On Wed, Dec 24, 2014 at 05:00:05PM +0100, Stefan Agner wrote:
> On 2014-12-19 10:55, Sanchayan Maity wrote:
> > Using hw_write_id_reg and hw_read_id_reg to write and read
> > identification registers contents. This can be used to get
> > controller information, change some system configurations
> > and so on.
>
> Checkpatch is complaining about DOS line endings and some trailing
> whitespace. This applies to all three patches.
>
> >
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > ---
> > drivers/usb/chipidea/ci.h | 53 +++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 53 insertions(+)
> >
> > diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
> > index ea40626..94db636 100644
> > --- a/drivers/usb/chipidea/ci.h
> > +++ b/drivers/usb/chipidea/ci.h
> > @@ -29,6 +29,15 @@
> > /******************************************************************************
> > * REGISTERS
> > *****************************************************************************/
> > +/* Identification Registers */
> > +#define ID_ID 0x0
> > +#define ID_HWGENERAL 0x4
> > +#define ID_HWHOST 0x8
> > +#define ID_HWDEVICE 0xc
> > +#define ID_HWTXBUF 0x10
> > +#define ID_HWRXBUF 0x14
> > +#define ID_SBUSCFG 0x90
> > +
> > /* register indices */
> > enum ci_hw_regs {
> > CAP_CAPLENGTH,
> > @@ -97,6 +106,18 @@ enum ci_role {
> > CI_ROLE_END,
> > };
> >
> > +enum CI_REVISION {
>
> Usually the enum names are small caps, only the labels are capitalized.
> I would suggest use ci_revision here (similar to the enum above).
I will change it.
>
> > + CI_REVISION_1X = 10, /* Revision 1.x */
> > + CI_REVISION_20 = 20, /* Revision 2.0 */
> > + CI_REVISION_21, /* Revision 2.1 */
> > + CI_REVISION_22, /* Revision 2.2 */
> > + CI_REVISION_23, /* Revision 2.3 */
> > + CI_REVISION_24, /* Revision 2.4 */
> > + CI_REVISION_25, /* Revision 2.5 */
> > + CI_REVISION_25_PLUS, /* Revision above than 2.5 */
> > + CI_REVISION_UNKNOWN = 99, /* Unknown Revision */
> > +};
> > +
> > /**
> > * struct ci_role_driver - host/gadget role driver
> > * @start: start this role
> > @@ -168,6 +189,7 @@ struct hw_bank {
> > * @b_sess_valid_event: indicates there is a vbus event, and handled
> > * at ci_otg_work
> > * @imx28_write_fix: Freescale imx28 needs swp instruction for writing
> > + * @rev: The revision number for controller
> > */
> > struct ci_hdrc {
> > struct device *dev;
> > @@ -207,6 +229,7 @@ struct ci_hdrc {
> > bool id_event;
> > bool b_sess_valid_event;
> > bool imx28_write_fix;
> > + enum CI_REVISION rev;
> > };
> >
> > static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
> > @@ -244,6 +267,36 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
> > }
> >
> > /**
> > + * hw_read_id_reg: reads from a identification register
> > + * @ci: the controller
> > + * @offset: offset from the beginning of identification registers region
> > + * @mask: bitfield mask
> > + *
> > + * This function returns register contents
> > + */
> > +static inline u32 hw_read_id_reg(struct ci_hdrc *ci, u32 offset, u32 mask)
> > +{
> > + return ioread32(ci->hw_bank.abs + offset) & mask;
> > +}
> > +
> > +/**
> > + * hw_write_id_reg: writes to a identification register
> > + * @ci: the controller
> > + * @offset: offset from the beginning of identification registers region
> > + * @mask: bitfield mask
> > + * @data: new value
> > + */
> > +static inline void hw_write_id_reg(struct ci_hdrc *ci, u32 offset,
> > + u32 mask, u32 data)
> > +{
> > + if (~mask)
> > + data = (ioread32(ci->hw_bank.abs + offset) & ~mask)
> > + | (data & mask);
> > +
> > + iowrite32(data, ci->hw_bank.abs + offset);
> > +}
>
> This function isn't used anywhere, does it make sense to write an ID
> register? The ones I see in Vybrid's RM are read-only anyway..
>
This API is used to write identification registers (offset, 0x00 - 0x90),
not only the ID register, the SBUSCFG (offset 0x90) attribute is read/write.
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2014-12-25 3:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 9:55 [PATCH 0/3] usb: chipidea: add one errata for revision 2.40a Sanchayan Maity
2014-12-19 9:55 ` [PATCH 1/3] usb: chipidea: Add identification registers access APIs Sanchayan Maity
2014-12-24 16:00 ` Stefan Agner
2014-12-24 16:15 ` Sanchayan Maity
2014-12-24 16:41 ` Stefan Agner
2014-12-25 2:13 ` Peter Chen
2014-12-25 3:33 ` Sanchayan Maity
2014-12-25 2:03 ` Peter Chen [this message]
2014-12-19 9:55 ` [PATCH 2/3] usb: chipidea: Add chipidea revision information Sanchayan Maity
2014-12-24 16:22 ` Stefan Agner
2014-12-25 2:30 ` Peter Chen
2014-12-19 9:55 ` [PATCH 3/3] usb: chipidea: Add errata for revision 2.40a Sanchayan Maity
2014-12-22 1:18 ` [PATCH 0/3] usb: chipidea: add one " Peter Chen
2014-12-22 13:09 ` Sanchayan Maity
2014-12-23 0:09 ` Peter Chen
2014-12-23 4:11 ` Sanchayan Maity
2014-12-24 7:50 ` Sanchayan Maity
2014-12-24 9:00 ` Peter Chen
2014-12-24 9:20 ` Sanchayan Maity
2014-12-24 15:42 ` Stefan Agner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141225020259.GA5077@shlinux2 \
--to=peter.chen@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=maitysanchayan@gmail.com \
--cc=stefan@agner.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox