Ejemplo n.º 1
0
int at91_board_act8865_set_reg_voltage(void)
{
	unsigned char reg, value;
	int ret;

	/* Check ACT8865 I2C interface */
	if (act8865_check_i2c_disabled())
		return 0;

	/* Enable REG2 output 1.25V */
	reg = REG2_0;
	value = ACT8865_1V25;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG2 output 1250mV\n");
		return -1;
	}

	/* Enable REG4(VDDANA) output 3.3V */
	reg = REG4_0;
	value = ACT8865_3V3;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG4 output 3300mV\n");
		return -1;
	}

	return 0;
}
Ejemplo n.º 2
0
int at91_board_act8865_set_reg_voltage(void)
{
	unsigned char reg, value;
	int ret;

	/* Check ACT8865 I2C interface */
	if (act8865_check_i2c_disabled())
		return 0;

	/* Enable REG2 output 1.2V */
	reg = REG2_1;
	value = ACT8865_1V2;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG2 output 1200mV\n");
		return -1;
	}

	/* Enable REG4 output 2.5V */
	reg = REG4_0;
	value = ACT8865_2V5;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG4 output 2500mV\n");
		return -1;
	}

	/* Enable REG5 output 3.3V */
	reg = REG5_0;
	value = ACT8865_3V3;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG5 output 3300mV\n");
		return -1;
	}

	/* Enable REG6 output 2.5V */
	reg = REG6_0;
	value = ACT8865_2V5;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG6 output 2500mV\n");
		return -1;
	}

	/* Enable REG7 output 1.8V */
	reg = REG7_0;
	value = ACT8865_1V8;
	ret = act8865_set_reg_voltage(reg, value);
	if (ret) {
		dbg_loud("ACT8865: Failed to make REG7 output 1800mV\n");
		return -1;
	}

	return 0;
}
Ejemplo n.º 3
0
static int act8865_workaround_disable_i2c(void)
{
	unsigned char value;
	unsigned char i;

	/* Check ACT8865 I2C interface */
	if (act8865_check_i2c_disabled())
		return 0;

	/* Disable ACT8865 I2C interface */
	for (i = 0; i < ARRAY_SIZE(version_array); i++) {
		value = version_array[i].set_value;
		act8865_disable_i2c_sequence(value);
		if (act8865_check_i2c_disabled())
			break;
	}

	if (i >= ARRAY_SIZE(version_array)) {
		dbg_loud("ACT8865: Failed to disable I2C interface\n");
		return -1;
	}

	dbg_info("ACT8865: Disable ACT8865's I2C interface\n");

	return 0;
}
Ejemplo n.º 4
0
int load_ek_at24xx(unsigned char *buff, unsigned int length)
{
	unsigned char dev_addr = EK_AT24XX_ADDR;
	unsigned char offset = EK_INFO_OFFSET;
	int ret = 0;
	unsigned int i;
	unsigned char *tmp = buff;

	ret = at24_read(dev_addr, offset, buff, length);

	dbg_loud("EEPROM Buff:\n");
	for (i = 0; i < length; i++)
		dbg_loud("%d ", *tmp++);
	dbg_loud("\n");

	return ret;
}
Ejemplo n.º 5
0
static int phys_enter_power_down(void)
{
	struct mii_bus macb_mii_bus;

#if defined(CONFIG_MAC0_PHY)
	gmac0_hw_init();

	macb_mii_bus.name = "GMAC0 KSZ8081RNB";
	macb_mii_bus.reg_base = (void *)AT91C_BASE_GMAC;
	macb_mii_bus.phy_addr = 1;

	pmc_enable_periph_clock(AT91C_ID_GMAC);

	if (phy_power_down_mode(&macb_mii_bus)) {
		dbg_loud("%s: Failed to enter power down mode\n",
						macb_mii_bus.name);
	}

	pmc_disable_periph_clock(AT91C_ID_GMAC);
#endif

#if defined(CONFIG_MAC1_PHY)
	gmac1_hw_init();

	macb_mii_bus.name = "GMAC1 KSZ8081RNB";
	macb_mii_bus.reg_base = (void *)AT91C_BASE_GMAC1;
	macb_mii_bus.phy_addr = 1;

	pmc_enable_periph_clock(AT91C_ID_GMAC1);

	if (phy_power_down_mode(&macb_mii_bus)) {
		dbg_loud("%s: Failed to enter power down mode\n",
						macb_mii_bus.name);
	}

	pmc_disable_periph_clock(AT91C_ID_GMAC1);
#endif

	return 0;
}
Ejemplo n.º 6
0
static int at24_read(unsigned char device_addr, unsigned char internal_addr,
			unsigned char *buff, unsigned int length)
{
	unsigned char iaddr_size = 1;
	unsigned int bus;
	int ret = 0;

	bus = at24_get_twi_bus();

	ret = twi_read(bus, device_addr, internal_addr, iaddr_size, buff, length);
	if (ret)
		dbg_loud("EEPROM: Failed to read\n");

	return ret;
}
Ejemplo n.º 7
0
static int SiI9022_write(unsigned char reg_addr, unsigned char data)
{
	unsigned int bus;
	int ret;

	bus = SiI9022_get_twi_bus();

	ret = twi_write(bus, SiI9022_ADDR, reg_addr, 1, &data, 1);
	if (ret) {
		dbg_loud("SiI9022: Failed to write on TWI bus: %d\n", bus);
		return -1;
	}

	return 0;
}
Ejemplo n.º 8
0
void redirect_interrupts_to_nsaic(void)
{
	unsigned int key32;

	if (!(readl(SFR_AICREDIR + AT91C_BASE_SFR) & 0x01)) {
		key32 = readl(SFR_SN1 + AT91C_BASE_SFR) ^ AICREDIR_KEY;
		writel(((key32 & ~0x01) | 0x1), SFR_AICREDIR + AT91C_BASE_SFR);
			/* bits[31:1] = key */
			/* bit[0] = 1 => all interrupts redirected to AIC */
			/* bit[0] = 0 => secure interrupts directed to SAIC,
						others to AIC (default) */

		if ((readl(SFR_AICREDIR + AT91C_BASE_SFR) & 0x01))
			dbg_loud("All interrupts redirected to AIC\n");
	}
}
Ejemplo n.º 9
0
static int SiI9022_read(unsigned char reg_addr, unsigned char *data)
{
	unsigned int bus;
	int ret;

	bus = SiI9022_get_twi_bus();

	ret = twi_read(bus, SiI9022_ADDR,
				reg_addr, 1, (unsigned char *)data, 1);
	if (ret) {
		dbg_loud("SiI9022: Failed to read on TWI bus: %d\n", bus);
		return -1;
	}

	return 0;
}
Ejemplo n.º 10
0
static int load_1wire_info(unsigned char *buff, unsigned int size,
			   unsigned int *psn, unsigned int *prev)
{
	board_info_t board_info;
	board_info_t *bd_info = &board_info;
	unsigned int count;
	unsigned int parsing = 0;
	int i;

	memset(bd_info, 0, sizeof(*bd_info));

	dbg_info("1-Wire: Loading 1-Wire information ...\n");

	count = enumerate_all_rom();
	if (!count) {
		dbg_info("WARNING: 1-Wire: No 1-Wire chip found\n");
		return -1;
	}

	dbg_info("1-Wire: BoardName | [Revid] | VendorName\n");

	for (i = 0; i < count; i++) {
		if (ds24xx_read_memory(i, 0, 0, size, buff) < 0) {
			dbg_info("WARNING: 1-Wire: Failed to read from 1-Wire chip!\n");
			return -1;
		}

		dbg_loud("board: #%d: ", i);
#if (BOOTSTRAP_DEBUG_LEVEL >= DEBUG_LOUD)
		dbg_hexdump(buff, size, DUMP_WIDTH_BIT_8);
#endif

		if (get_board_hw_info(buff, i, bd_info))
			continue;

		if (construct_sn_rev(bd_info, psn, prev))
			continue;

		parsing++;
	}

	if (!parsing)
		return -1;

	return 0;
}
Ejemplo n.º 11
0
int act8865_set_power_saving_mode(void)
{
	unsigned char mode = ACT8865_MODE_POWER_SAVING;
	unsigned char reg_list[] = {REG1_2, REG2_2, REG3_2};
	unsigned char reg;
	unsigned i;
	int ret;

	if (act8865_check_i2c_disabled())
		return 0;

	for (i = 0; i < ARRAY_SIZE(reg_list); i++) {
		reg = reg_list[i];
		ret = act8865_set_reg_mode(reg, mode);
		if (ret)
			dbg_loud("ACT8865: Failed to set Power-saving mode\n");
	}

	dbg_info("ACT8865: Set REG1/REG2/REG3 Power-saving mode\n");

	return 0;
}
Ejemplo n.º 12
0
/*******************************************************************************
 * SN layout
 *
 *   31  30         25         20         15         10         5          0
 *   -----------------------------------------------------------------------
 *   |   | Vendor ID| Board ID | Vendor ID| Board ID | Vendor ID| Board ID |
 *   -----------------------------------------------------------------------
 *       |         EK          |         DM          |         CPU         |
 *
 * Rev layout
 *
 *   31              24     21     18     15         10         5          0
 *   -----------------------------------------------------------------------
 *   |               |  EK  |  DM  |  CPU |    EK    |    DM    |   CPU    |
 *   -----------------------------------------------------------------------
 *                   |     Revision id    |        Revision Code           |
 *
 *******************************************************************************
 */
void load_1wire_info(void)
{
	int i, j;
	unsigned int	cnt;
	unsigned int	size = LEN_ONE_WIRE_INFO;
	struct board_info	board_info;
	struct board_info	*bd_info;
#if defined(CONFIG_SAMA5D4EK)
	int missing = BOARD_TYPE_EK_MASK | BOARD_TYPE_DM_MASK;
#else
	int missing = BOARD_TYPE_MASK;
#endif
	unsigned char *tmp = buf;

	memset(&board_info, 0, sizeof(board_info));
	bd_info= &board_info;

	dbg_info("1-Wire: Loading 1-Wire information ...\n");

	sn = rev = 0;

	cnt = enumerate_all_rom();
	if (!cnt) {
		dbg_info("WARNING: 1-Wire: No 1-Wire chip found\n ");
		goto err;
	}

	dbg_info("1-Wire: BoardName | [Revid] | VendorName\n");

	for (i = 0; i < cnt; i++) {
		if (ds24xx_read_memory(i, 0, 0, size, buf) < 0) {
			dbg_info("WARNING: 1-Wire: Failed to read from 1-Wire chip!\n");
			goto err;
		}

		dbg_loud("board: #%d: ", i);
		for (j = 0; j < size; j++)
			dbg_loud("%d ", *tmp++);

		dbg_loud("\n");

		if (get_board_info(buf,	i, bd_info)) {
			continue;
		}

		switch (bd_info->board_type) {
		case BOARD_TYPE_CPU:
			missing &= (BOARD_TYPE_MASK & ~BOARD_TYPE_CPU_MASK);
			sn  |= (bd_info->board_id & SN_MASK);
			sn  |= ((bd_info->vendor_id & VENDOR_MASK)
							<< CM_VENDOR_OFFSET);
			rev |= ((bd_info->revision_code - 'A') & REV_MASK);
			rev |= (((bd_info->revision_id - '0') & REV_ID_MASK)
							<< CM_REV_ID_OFFSET);
			break;

		case BOARD_TYPE_DM:
			missing &= (BOARD_TYPE_MASK & ~BOARD_TYPE_DM_MASK);
			sn  |= ((bd_info->board_id & SN_MASK) << DM_SN_OFFSET);
			sn  |= ((bd_info->vendor_id & VENDOR_MASK)
							<< DM_VENDOR_OFFSET);
			rev |= (((bd_info->revision_code - 'A') & REV_MASK)
							<< DM_REV_OFFSET);
			rev |= (((bd_info->revision_id - '0') & REV_ID_MASK)
							<< DM_REV_ID_OFFSET);
			break;

		case BOARD_TYPE_EK:
			missing &= (BOARD_TYPE_MASK & ~BOARD_TYPE_EK_MASK);
			sn  |= ((bd_info->board_id & SN_MASK) << EK_SN_OFFSET);
			sn  |= ((bd_info->vendor_id & VENDOR_MASK)
							<< EK_VENDOR_OFFSET);
			rev |= (((bd_info->revision_code - 'A') & REV_MASK)
							<< EK_REV_OFFSET);
			rev |= (((bd_info->revision_id - '0') & REV_ID_MASK)
							<< EK_REV_ID_OFFSET);
			break;

		default:
			dbg_info("WARNING: 1-Wire: Unknown board type\n");
			goto err;
		}
	}

	if (missing & BOARD_TYPE_CPU_MASK)
		dbg_info("1-Wire: Failed to read CM board information\n");

	if (missing & BOARD_TYPE_DM_MASK)
		dbg_info("1-Wire: Failed to read DM board information\n");

	if (missing & BOARD_TYPE_EK_MASK)
		dbg_info("1-Wire: Failed to read EK board information\n");

	goto save_info;

err:
	dbg_info("\n1-Wire: Using defalt information\n");

	sn = set_default_sn();
	rev = set_default_rev();

save_info:
#ifdef AT91C_BASE_GPBR
	/* save to GPBR #2 and #3 */
	dbg_info("\n1-Wire: SYS_GPBR2: %d, SYS_GPBR3: %d\n\n", sn, rev);

	writel(sn, AT91C_BASE_GPBR + 4 * 2);
	writel(rev, AT91C_BASE_GPBR + 4 * 3);
#else
	dbg_info("\n1-Wire: Board sn: %d, revsion: %d\n\n", sn, rev);
#endif

	return;
}
Ejemplo n.º 13
0
static int get_board_info(unsigned char *buffer,
				unsigned char bd_sn,
				struct board_info *bd_info)
{
	int i;
	char tmp[20];
	struct one_wire_info one_wire;
	struct one_wire_info *p = &one_wire;
	unsigned char *pbuf = buffer;

	char *boardname;
	char *vendorname;

	p->total_bytes = (unsigned char)*pbuf;

	pbuf = buffer + 1;
	for (i = 0; i < VENDOR_NAME_LEN; i++)
		p->vendor_name[i] = *pbuf++;

	pbuf = buffer + 11;
	for (i = 0; i < VENDOR_COUNTRY_LEN; i++)
		p->vendor_country[i] = *pbuf++;

	pbuf = buffer + 13;
	for (i = 0; i < BOARD_NAME_LEN; i++)
		p->board_name[i] = *pbuf++;

	p->year = *pbuf++;
	p->week = *pbuf++;
	p->revision_code = *pbuf++;
	p->revision_id = *pbuf++;
	p->bom_revision = *pbuf++;
	p->revision_mapping = *pbuf++;

	memset(tmp, 0, sizeof(tmp));

	for (i = 0; i < BOARD_NAME_LEN; i++) {
		if (p->board_name[i] == 0x20)
			break;

		tmp[i] = p->board_name[i];
	}

	for (i = 0; i < ARRAY_SIZE(board_list); i++) {
		if (strncmp(board_list[i].board_name, tmp,
			strlen(board_list[i].board_name)) == 0) {
			bd_info->board_type = board_list[i].board_type;
			bd_info->board_id = board_list[i].board_id;

			bd_info->revision_code
				= normalize_rev_code(p->revision_code);
			if (p->revision_mapping == 'B') {
				bd_info->revision_id
					= normalize_rev_id_map_b(p->revision_id);
				bd_info->bom_revision
					= normalize_bom_revision(p->bom_revision);
			} else {
				bd_info->revision_id
					= normalize_rev_id(p->revision_id);
			}

			break;
		}
	}

	if (i == ARRAY_SIZE(board_list)) {
		return -1;
	}

	boardname = board_list[i].board_name;

	dbg_loud("board: #%d: boardname: %s\n", bd_sn, boardname);

	memset(tmp, 0, sizeof(tmp));
	for (i = 0; i < VENDOR_NAME_LEN; i++) {
		if (p->vendor_name[i] == 0x20)
			break;
		tmp[i] = p->vendor_name[i];
	}

	for (i = 0; i < ARRAY_SIZE(vendor_list); i++) {
		if (strncmp(vendor_list[i].vendor_name, tmp,
			    strlen(vendor_list[i].vendor_name)) == 0) {
			bd_info->vendor_id = vendor_list[i].vendor_id;
			break;
		}
	}

	if (i == ARRAY_SIZE(vendor_list)) {
		return -1;
	}

	vendorname = vendor_list[i].vendor_name;

	dbg_loud("board: #%d: vendorname: %s\n", bd_sn, vendorname);

	dbg_info("  #%d", bd_sn);
	if (p->revision_mapping == 'B') {
		dbg_info("  %s [%c%c%c]      %s\n",
				boardname,
				bd_info->revision_code,
				bd_info->revision_id,
				bd_info->bom_revision,
				vendorname);
	} else {
		dbg_info("  %s [%c%c]      %s\n",
				boardname,
				bd_info->revision_code,
				bd_info->revision_id,
				vendorname);
	}

	return 0;
}
Ejemplo n.º 14
0
int SiI9022_enter_power_state_D3_Cold(void)
{
	unsigned char power_state = 0;
	unsigned char device_id = 0;
	unsigned int timeout = 10;
	int ret;

	/*
	 * D3 cold Note:It is necessary to unplug the HDMI connector,
	 * otherwise would not go to D3 cold.
	 */

	/* 1. Clear any pending interrupts via TPI 0x3D */
	ret = SiI9022_write(TPI_INTERRUPT_STATUS_REG, 0xFF);
	if (ret) {
		dbg_loud("SiI9022: Failed to clear any pending interrupts\n");
		return -1;
	}
	/* 2. Reset SiI9022A Tx via HW */
	ret = SiI9022_TxHW_Reset();
	if (ret) {
		dbg_loud("SiI9022: Failed to reset\n");
		return -1;
	}

	do {
		/* 3. Write device register 0xC7 = 0x00 to enter TPI mode */
		ret = SiI9022_write(TPI_ENABLE, 0x00);
		if (ret)
			dbg_loud("SiI9022: Failed to enter TPI mode\n");

		mdelay(100);

		power_state = TX_POWER_STATE_D0;
		ret = SiI9022_write(TPI_DEVICE_POWER_STATE_CTRL_REG,
								power_state);
		if (ret) {
			dbg_loud("SiI9022: Failed to write TPI 0x1E\n");
			return -1;
		}

		ret = SiI9022_read(TPI_DEVICE_ID, &device_id);
		if (ret)
			dbg_loud("SiI9022: Failed to 0x1b\n");
	} while ((--timeout) && (device_id == 0x0));

	if (device_id != SiI9022_DEVICE_ID) {
		dbg_loud("SiI9022: Not found\n");
		return -1;
	}

	/* 4. Set INT# source to Hotplug via TPI 0x3C[0] = 1b */
	ret = SiI9022_write(TPI_INTERRUPT_ENABLE_REG, HOT_PLUG_EVENT | 0x08);
	if (ret) {
		dbg_loud("SiI9022: Failed to Set INT# source to Hotplug\n");
		return -1;
	}

	/* 5. Clear any pending interrupts via TPI 0x3D*/
	ret = SiI9022_write(TPI_INTERRUPT_STATUS_REG, 0xFF);
	if (ret) {
		dbg_loud("SiI9022: Failed to clear any pending interrupts\n");
		return -1;
	}

	/* 6. Enter D3 Cold mode via TPI 0x1E[1:0] = 11b */
	power_state = 0x04;
	ret = SiI9022_write(TPI_DEVICE_POWER_STATE_CTRL_REG, power_state);
	if (ret) {
		dbg_loud("SiI9022: Failed to write TPI 0x1E\n");
		return -1;
	}

	power_state &= ~TX_POWER_STATE_MASK;
	power_state |= TX_POWER_STATE_D3;
	ret = SiI9022_write(TPI_DEVICE_POWER_STATE_CTRL_REG, power_state);
	if (ret) {
		dbg_loud("SiI9022: Failed to write TPI 0x1E\n");
		return -1;
	}

	dbg_info("HDMI SiI9022: Enter D3 Cold mode\n");

	return 0;
}