Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb271f3c authored by Peter Chen's avatar Peter Chen Committed by Greg Kroah-Hartman
Browse files

usb: chipidea: add chipidea revision information



Define ci_get_revision API to know the controller revision
information according to chipidea 1.1a, 2.0a and 2.5a spec.
Besides, add one entry at struct ci_hdrc to indicate revision
information, it can be used for adding different code for
revisions, eg kinds of errata.

Reviewed-by: default avatarStefan Agner <stefan@agner.ch>
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 655d32e9
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,16 @@


#include <linux/usb/ehci_def.h>
#include <linux/usb/ehci_def.h>


/*
 * ID
 * For 1.x revision, bit24 - bit31 are reserved
 * For 2.x revision, bit25 - bit28 are 0x2
 */
#define TAG		      (0x1F << 16)
#define REVISION	      (0xF << 21)
#define VERSION		      (0xF << 25)
#define CIVERSION	      (0x7 << 29)

/* HCCPARAMS */
/* HCCPARAMS */
#define HCCPARAMS_LEN         BIT(17)
#define HCCPARAMS_LEN         BIT(17)


+14 −0
Original line number Original line Diff line number Diff line
@@ -106,6 +106,18 @@ enum ci_role {
	CI_ROLE_END,
	CI_ROLE_END,
};
};


enum ci_revision {
	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
 * struct ci_role_driver - host/gadget role driver
 * @start: start this role
 * @start: start this role
@@ -181,6 +193,7 @@ struct hw_bank {
 * @supports_runtime_pm: if runtime pm is supported
 * @supports_runtime_pm: if runtime pm is supported
 * @in_lpm: if the core in low power mode
 * @in_lpm: if the core in low power mode
 * @wakeup_int: if wakeup interrupt occur
 * @wakeup_int: if wakeup interrupt occur
 * @rev: The revision number for controller
 */
 */
struct ci_hdrc {
struct ci_hdrc {
	struct device			*dev;
	struct device			*dev;
@@ -226,6 +239,7 @@ struct ci_hdrc {
	bool				supports_runtime_pm;
	bool				supports_runtime_pm;
	bool				in_lpm;
	bool				in_lpm;
	bool				wakeup_int;
	bool				wakeup_int;
	enum ci_revision		rev;
};
};


static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
+21 −2
Original line number Original line Diff line number Diff line
@@ -137,6 +137,22 @@ static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
	return 0;
	return 0;
}
}


static enum ci_revision ci_get_revision(struct ci_hdrc *ci)
{
	int ver = hw_read_id_reg(ci, ID_ID, VERSION) >> __ffs(VERSION);
	enum ci_revision rev = CI_REVISION_UNKNOWN;

	if (ver == 0x2) {
		rev = hw_read_id_reg(ci, ID_ID, REVISION)
			>> __ffs(REVISION);
		rev += CI_REVISION_20;
	} else if (ver == 0x0) {
		rev = CI_REVISION_1X;
	}

	return rev;
}

/**
/**
 * hw_read_intr_enable: returns interrupt enable register
 * hw_read_intr_enable: returns interrupt enable register
 *
 *
@@ -251,8 +267,11 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
	/* Clear all interrupts status bits*/
	/* Clear all interrupts status bits*/
	hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff);
	hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff);


	dev_dbg(ci->dev, "ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n",
	ci->rev = ci_get_revision(ci);
		ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);

	dev_dbg(ci->dev,
		"ChipIdea HDRC found, revision: %d, lpm: %d; cap: %p op: %p\n",
		ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);


	/* setup lock mode ? */
	/* setup lock mode ? */