chrome_ec.c (266785) | chrome_ec.c (266945) |
---|---|
1/*- 2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Samsung Chromebook Embedded Controller 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Samsung Chromebook Embedded Controller 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/arm/samsung/exynos/chrome_ec.c 266785 2014-05-28 06:11:12Z br $"); | 32__FBSDID("$FreeBSD: head/sys/arm/samsung/exynos/chrome_ec.c 266945 2014-06-01 08:45:27Z br $"); |
33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/malloc.h> 40#include <sys/rman.h> --- 119 unchanged lines hidden (view full) --- 160{ 161 struct ec_softc *sc; 162 uint8_t *msg_dout; 163 uint8_t *msg_dinp; 164 int ret; 165 int i; 166 167 msg_dout = malloc(dout_len + 4, M_DEVBUF, M_NOWAIT); | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/malloc.h> 40#include <sys/rman.h> --- 119 unchanged lines hidden (view full) --- 160{ 161 struct ec_softc *sc; 162 uint8_t *msg_dout; 163 uint8_t *msg_dinp; 164 int ret; 165 int i; 166 167 msg_dout = malloc(dout_len + 4, M_DEVBUF, M_NOWAIT); |
168 msg_dinp = malloc(dinp_len + 4, M_DEVBUF, M_NOWAIT); | 168 msg_dinp = malloc(dinp_len + 3, M_DEVBUF, M_NOWAIT); |
169 170 if (ec_sc == NULL) 171 return (-1); 172 173 sc = ec_sc; 174 175 msg_dout[0] = EC_CMD_VERSION0; 176 msg_dout[1] = cmd; 177 msg_dout[2] = dout_len; 178 179 for (i = 0; i < dout_len; i++) { 180 msg_dout[i + 3] = dout[i]; 181 }; 182 183 fill_checksum(msg_dout, dout_len + 3); 184 185 struct iic_msg msgs[] = { 186 { 0x1e, IIC_M_WR, dout_len + 4, msg_dout, }, | 169 170 if (ec_sc == NULL) 171 return (-1); 172 173 sc = ec_sc; 174 175 msg_dout[0] = EC_CMD_VERSION0; 176 msg_dout[1] = cmd; 177 msg_dout[2] = dout_len; 178 179 for (i = 0; i < dout_len; i++) { 180 msg_dout[i + 3] = dout[i]; 181 }; 182 183 fill_checksum(msg_dout, dout_len + 3); 184 185 struct iic_msg msgs[] = { 186 { 0x1e, IIC_M_WR, dout_len + 4, msg_dout, }, |
187 { 0x1e, IIC_M_RD, dinp_len + 4, msg_dinp, }, | 187 { 0x1e, IIC_M_RD, dinp_len + 3, msg_dinp, }, |
188 }; 189 190 ret = iicbus_transfer(sc->dev, msgs, 2); 191 if (ret != 0) { 192 device_printf(sc->dev, "i2c transfer returned %d\n", ret); 193 free(msg_dout, M_DEVBUF); 194 free(msg_dinp, M_DEVBUF); 195 return (-1); 196 } 197 198 for (i = 0; i < dinp_len; i++) { | 188 }; 189 190 ret = iicbus_transfer(sc->dev, msgs, 2); 191 if (ret != 0) { 192 device_printf(sc->dev, "i2c transfer returned %d\n", ret); 193 free(msg_dout, M_DEVBUF); 194 free(msg_dinp, M_DEVBUF); 195 return (-1); 196 } 197 198 for (i = 0; i < dinp_len; i++) { |
199 dinp[i] = msg_dinp[i + 3]; | 199 dinp[i] = msg_dinp[i + 2]; |
200 }; 201 202 free(msg_dout, M_DEVBUF); 203 free(msg_dinp, M_DEVBUF); 204 return (0); 205} 206 207int ec_hello(void) --- 96 unchanged lines hidden --- | 200 }; 201 202 free(msg_dout, M_DEVBUF); 203 free(msg_dinp, M_DEVBUF); 204 return (0); 205} 206 207int ec_hello(void) --- 96 unchanged lines hidden --- |