View | Details | Raw Unified | Return to bug 239697
Collapse All | Expand All

(-)sys/arm/ti/am335x/am335x_pmic.c (-16 / +2 lines)
Lines 79-108 Link Here
79
static int
79
static int
80
am335x_pmic_read(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
80
am335x_pmic_read(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
81
{
81
{
82
	struct am335x_pmic_softc *sc = device_get_softc(dev);
82
	return (iicdev_readfrom(dev, addr, data, size, IIC_INTRWAIT));
83
	struct iic_msg msg[] = {
84
		{ sc->sc_addr, IIC_M_WR, 1, &addr },
85
		{ sc->sc_addr, IIC_M_RD, size, data },
86
	};
87
	return (iicbus_transfer(dev, msg, 2));
88
}
83
}
89
84
90
static int
85
static int
91
am335x_pmic_write(device_t dev, uint8_t address, uint8_t *data, uint8_t size)
86
am335x_pmic_write(device_t dev, uint8_t address, uint8_t *data, uint8_t size)
92
{
87
{
93
	uint8_t buffer[MAX_IIC_DATA_SIZE + 1];
94
	struct am335x_pmic_softc *sc = device_get_softc(dev);
95
	struct iic_msg msg[] = {
96
		{ sc->sc_addr, IIC_M_WR, size + 1, buffer },
97
	};
98
99
	if (size > MAX_IIC_DATA_SIZE)
88
	if (size > MAX_IIC_DATA_SIZE)
100
		return (ENOMEM);
89
		return (ENOMEM);
101
90
102
	buffer[0] = address;
91
	return (iicdev_writeto(dev, address, data, size, IIC_INTRWAIT));
103
	memcpy(buffer + 1, data, size);
104
105
	return (iicbus_transfer(dev, msg, 1));
106
}
92
}
107
93
108
static void
94
static void

Return to bug 239697