dm: cros_ec: Convert cros_ec LPC driver to driver model
This is the last driver to be converted. It requires an LPC bus and a special check_version() method. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
90b16d1491
commit
72a38e06a2
@ -10,3 +10,4 @@ CONFIG_VIDEO_VESA=y
|
|||||||
CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
|
CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
|
||||||
CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
|
CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
|
||||||
CONFIG_DM_PCI=y
|
CONFIG_DM_PCI=y
|
||||||
|
CONFIG_CROS_EC_LPC=y
|
||||||
|
@ -681,10 +681,22 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
|
|||||||
struct ec_params_hello req;
|
struct ec_params_hello req;
|
||||||
struct ec_response_hello *resp;
|
struct ec_response_hello *resp;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_CROS_EC
|
||||||
|
struct dm_cros_ec_ops *ops;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ops = dm_cros_ec_get_ops(dev->dev);
|
||||||
|
if (ops->check_version) {
|
||||||
|
ret = ops->check_version(dev->dev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#else
|
||||||
#ifdef CONFIG_CROS_EC_LPC
|
#ifdef CONFIG_CROS_EC_LPC
|
||||||
/* LPC has its own way of doing this */
|
/* LPC has its own way of doing this */
|
||||||
if (dev->interface == CROS_EC_IF_LPC)
|
if (dev->interface == CROS_EC_IF_LPC)
|
||||||
return cros_ec_lpc_check_version(dev);
|
return cros_ec_lpc_check_version(dev);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <dm.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <cros_ec.h>
|
#include <cros_ec.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
@ -40,10 +41,18 @@ static int wait_for_sync(struct cros_ec_dev *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_CROS_EC
|
||||||
|
int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version,
|
||||||
|
const uint8_t *dout, int dout_len,
|
||||||
|
uint8_t **dinp, int din_len)
|
||||||
|
{
|
||||||
|
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
||||||
|
#else
|
||||||
int cros_ec_lpc_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
int cros_ec_lpc_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
||||||
const uint8_t *dout, int dout_len,
|
const uint8_t *dout, int dout_len,
|
||||||
uint8_t **dinp, int din_len)
|
uint8_t **dinp, int din_len)
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
const int cmd_addr = EC_LPC_ADDR_HOST_CMD;
|
const int cmd_addr = EC_LPC_ADDR_HOST_CMD;
|
||||||
const int data_addr = EC_LPC_ADDR_HOST_DATA;
|
const int data_addr = EC_LPC_ADDR_HOST_DATA;
|
||||||
const int args_addr = EC_LPC_ADDR_HOST_ARGS;
|
const int args_addr = EC_LPC_ADDR_HOST_ARGS;
|
||||||
@ -178,7 +187,11 @@ int cros_ec_lpc_init(struct cros_ec_dev *dev, const void *blob)
|
|||||||
* seeing whether the EC sets the EC_HOST_ARGS_FLAG_FROM_HOST flag
|
* seeing whether the EC sets the EC_HOST_ARGS_FLAG_FROM_HOST flag
|
||||||
* in args when it responds.
|
* in args when it responds.
|
||||||
*/
|
*/
|
||||||
|
#ifdef CONFIG_DM_CROS_EC
|
||||||
|
static int cros_ec_lpc_check_version(struct udevice *dev)
|
||||||
|
#else
|
||||||
int cros_ec_lpc_check_version(struct cros_ec_dev *dev)
|
int cros_ec_lpc_check_version(struct cros_ec_dev *dev)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID) == 'E' &&
|
if (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID) == 'E' &&
|
||||||
inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1)
|
inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1)
|
||||||
@ -192,3 +205,28 @@ int cros_ec_lpc_check_version(struct cros_ec_dev *dev)
|
|||||||
printf("%s: ERROR: old EC interface not supported\n", __func__);
|
printf("%s: ERROR: old EC interface not supported\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_CROS_EC
|
||||||
|
static int cros_ec_probe(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return cros_ec_register(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct dm_cros_ec_ops cros_ec_ops = {
|
||||||
|
.command = cros_ec_lpc_command,
|
||||||
|
.check_version = cros_ec_lpc_check_version,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct udevice_id cros_ec_ids[] = {
|
||||||
|
{ .compatible = "google,cros-ec" },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
U_BOOT_DRIVER(cros_ec_lpc) = {
|
||||||
|
.name = "cros_ec",
|
||||||
|
.id = UCLASS_CROS_EC,
|
||||||
|
.of_match = cros_ec_ids,
|
||||||
|
.probe = cros_ec_probe,
|
||||||
|
.ops = &cros_ec_ops,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user