[U-Boot] [PATCH 05/11] usb-gadget: add FOTG210 USB gadget support

Marek Vasut marex at denx.de
Sat Mar 30 07:27:27 CET 2013


Dear Kuo-Jung Su,

> From: Kuo-Jung Su <dantesu at faraday-tech.com>
> 
> This patch would try to use Faraday FOTG210 to implement
> a USB RNDIS Ethernet.
> 
> Signed-off-by: Kuo-Jung Su <dantesu at faraday-tech.com>

[...]

> +static inline int
> +ep_reset(struct fotg210_chip *chip, uint8_t ep_addr)
> +{
> +	int ep = ep_addr & USB_ENDPOINT_NUMBER_MASK;
> +
> +	if (ep_addr & USB_DIR_IN) {
> +		/* input */
> +		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) |= BIT(12);
> +		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(12);
> +		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(11);
> +	} else {
> +		/* output */
> +		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) |= BIT(12);
> +		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(12);
> +		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(11);
> +	}

Use readl(), writel(), clrsetbits_le32() etc.

For example see drivers/i2c/mxs_i2c.c

[...]

> +/*
> + * Global Registers
> + */
> +#define REG_ISR         0x0C0    /* Interrupt Status */
> +#define REG_IMR         0x0C4    /* Interrupt Control */

Use structure based access, ie.

arch/arm/include/asm/arch-mxs/regs-i2c.h

struct regs {
	uint32_t reg1;
	uint32_t reg2;
...
};

writel(val, &regs->reg1);


More information about the U-Boot mailing list