arch/arm/mach-orion5x/terastation_pro2-setup.c

Source file repositories/reference/linux-study-clean/arch/arm/mach-orion5x/terastation_pro2-setup.c

File Facts

System
Linux kernel
Corpus path
arch/arm/mach-orion5x/terastation_pro2-setup.c
Extension
.c
Size
9394 bytes
Lines
367
Domain
Architecture Layer
Bucket
arch/arm
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

subsys_initcall(tsp2_pci_init);

/*****************************************************************************
 * Ethernet
 ****************************************************************************/

static struct mv643xx_eth_platform_data tsp2_eth_data = {
	.phy_addr	= 0,
};

/*****************************************************************************
 * RTC 5C372a on I2C bus
 ****************************************************************************/

#define TSP2_RTC_GPIO	9

static struct i2c_board_info __initdata tsp2_i2c_rtc = {
	I2C_BOARD_INFO("rs5c372a", 0x32),
};

/*****************************************************************************
 * Terastation Pro II specific power off method via UART1-attached
 * microcontroller
 ****************************************************************************/

#define UART1_REG(x)	(UART1_VIRT_BASE + ((UART_##x) << 2))

static int tsp2_miconread(unsigned char *buf, int count)
{
	int i;
	int timeout;

	for (i = 0; i < count; i++) {
		timeout = 10;

		while (!(readl(UART1_REG(LSR)) & UART_LSR_DR)) {
			if (--timeout == 0)
				break;
			udelay(1000);
		}

		if (timeout == 0)
			break;
		buf[i] = readl(UART1_REG(RX));
	}

	/* return read bytes */
	return i;
}

static int tsp2_miconwrite(const unsigned char *buf, int count)
{
	int i = 0;

	while (count--) {
		while (!(readl(UART1_REG(LSR)) & UART_LSR_THRE))
			barrier();
		writel(buf[i++], UART1_REG(TX));
	}

	return 0;
}

static int tsp2_miconsend(const unsigned char *data, int count)
{
	int i;
	unsigned char checksum = 0;
	unsigned char recv_buf[40];
	unsigned char send_buf[40];
	unsigned char correct_ack[3];
	int retry = 2;

	/* Generate checksum */
	for (i = 0; i < count; i++)
		checksum -=  data[i];

	do {
		/* Send data */
		tsp2_miconwrite(data, count);

		/* send checksum */
		tsp2_miconwrite(&checksum, 1);

		if (tsp2_miconread(recv_buf, sizeof(recv_buf)) <= 3) {
			printk(KERN_ERR ">%s: receive failed.\n", __func__);

			/* send preamble to clear the receive buffer */
			memset(&send_buf, 0xff, sizeof(send_buf));
			tsp2_miconwrite(send_buf, sizeof(send_buf));

Annotation

Implementation Notes