From b953ec2bca1ebe059366e870eb4bec5e7af9c36b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Tue, 27 Apr 2021 11:02:19 +0200 Subject: dm: define LOG_CATEGORY for all uclass Define LOG_CATEGORY for all uclass to allow filtering with log command. Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- drivers/misc/fs_loader.c | 3 +++ drivers/misc/i2c_eeprom.c | 2 ++ drivers/misc/misc-uclass.c | 2 ++ drivers/misc/p2sb-uclass.c | 2 ++ drivers/misc/pwrseq-uclass.c | 2 ++ 5 files changed, 11 insertions(+) (limited to 'drivers/misc') diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c index e77b3af770e..0139bd66ba7 100644 --- a/drivers/misc/fs_loader.c +++ b/drivers/misc/fs_loader.c @@ -3,6 +3,9 @@ * Copyright (C) 2018-2019 Intel Corporation * */ + +#define LOG_CATEGORY UCLASS_FS_FIRMWARE_LOADER + #include #include #include diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c index 5926c91a2ec..3b249842f8b 100644 --- a/drivers/misc/i2c_eeprom.c +++ b/drivers/misc/i2c_eeprom.c @@ -3,6 +3,8 @@ * Copyright (c) 2014 Google, Inc */ +#define LOG_CATEGORY UCLASS_I2C_EEPROM + #include #include #include diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c index 55381edc980..72720b0e590 100644 --- a/drivers/misc/misc-uclass.c +++ b/drivers/misc/misc-uclass.c @@ -3,6 +3,8 @@ * Copyright (C) 2010 Thomas Chou */ +#define LOG_CATEGORY UCLASS_MISC + #include #include #include diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c index ac2852559f5..94d273de9b3 100644 --- a/drivers/misc/p2sb-uclass.c +++ b/drivers/misc/p2sb-uclass.c @@ -6,6 +6,8 @@ * Written by Simon Glass */ +#define LOG_CATEGORY UCLASS_P2SB + #include #include #include diff --git a/drivers/misc/pwrseq-uclass.c b/drivers/misc/pwrseq-uclass.c index c8f6c46069b..a0f24e1bf3a 100644 --- a/drivers/misc/pwrseq-uclass.c +++ b/drivers/misc/pwrseq-uclass.c @@ -3,6 +3,8 @@ * Copyright (c) 2015 Google, Inc */ +#define LOG_CATEGORY UCLASS_PWRSEQ + #include #include #include -- cgit v1.2.3 From e712245d08d95fac6467fd0d05a12d6506aeda2d Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 19 May 2021 19:33:31 +0300 Subject: sandbox: cros-ec: Add tests for the Chromium OS EC PWM driver This patch adds a limited pulse-width modulator to sandbox's Chromium OS Embedded Controller emulation. The emulated PWM device supports multiple channels but can only set a duty cycle for each, as the actual EC doesn't expose any functionality or information other than that. Though the EC supports specifying the PWM channel by its type (e.g. display backlight, keyboard backlight), this is not implemented in the emulation as nothing in U-Boot uses this type specification. This emulated PWM device is then used to test the Chromium OS PWM driver in sandbox. Adding the required device node to the sandbox test device-tree unfortunately makes it the first PWM device, so this also touches some other tests to make sure they still use the sandbox PWM. Signed-off-by: Alper Nebi Yasak Reviewed-by: Simon Glass --- drivers/misc/cros_ec_sandbox.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'drivers/misc') diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index bc01df0904e..db5e3b0f51a 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -64,6 +64,7 @@ struct ec_keymatrix_entry { enum { VSTORE_SLOT_COUNT = 4, + PWM_CHANNEL_COUNT = 4, }; struct vstore_slot { @@ -71,6 +72,10 @@ struct vstore_slot { u8 data[EC_VSTORE_SLOT_SIZE]; }; +struct ec_pwm_channel { + uint duty; /* not ns, EC_PWM_MAX_DUTY = 100% */ +}; + /** * struct ec_state - Information about the EC state * @@ -85,6 +90,7 @@ struct vstore_slot { * @recovery_req: Keyboard recovery requested * @test_flags: Flags that control behaviour for tests * @slot_locked: Locked vstore slots (mask) + * @pwm: Information per PWM channel */ struct ec_state { u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2]; @@ -98,6 +104,7 @@ struct ec_state { bool recovery_req; uint test_flags; struct vstore_slot slot[VSTORE_SLOT_COUNT]; + struct ec_pwm_channel pwm[PWM_CHANNEL_COUNT]; } s_state, *g_state; /** @@ -554,6 +561,33 @@ static int process_cmd(struct ec_state *ec, len = sizeof(*resp); break; } + case EC_CMD_PWM_GET_DUTY: { + const struct ec_params_pwm_get_duty *req = req_data; + struct ec_response_pwm_get_duty *resp = resp_data; + struct ec_pwm_channel *pwm; + + if (req->pwm_type != EC_PWM_TYPE_GENERIC) + return -EINVAL; + if (req->index >= PWM_CHANNEL_COUNT) + return -EINVAL; + pwm = &ec->pwm[req->index]; + resp->duty = pwm->duty; + len = sizeof(*resp); + break; + } + case EC_CMD_PWM_SET_DUTY: { + const struct ec_params_pwm_set_duty *req = req_data; + struct ec_pwm_channel *pwm; + + if (req->pwm_type != EC_PWM_TYPE_GENERIC) + return -EINVAL; + if (req->index >= PWM_CHANNEL_COUNT) + return -EINVAL; + pwm = &ec->pwm[req->index]; + pwm->duty = req->duty; + len = 0; + break; + } default: printf(" ** Unknown EC command %#02x\n", req_hdr->command); return -1; @@ -619,6 +653,19 @@ void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags) ec->test_flags = flags; } +int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty) +{ + struct ec_state *ec = dev_get_priv(dev); + struct ec_pwm_channel *pwm; + + if (index >= PWM_CHANNEL_COUNT) + return -ENOSPC; + pwm = &ec->pwm[index]; + *duty = pwm->duty; + + return 0; +} + int cros_ec_probe(struct udevice *dev) { struct ec_state *ec = dev_get_priv(dev); -- cgit v1.2.3