|
@@ -64,6 +64,7 @@ struct ec_keymatrix_entry {
|
|
|
|
|
|
enum {
|
|
enum {
|
|
VSTORE_SLOT_COUNT = 4,
|
|
VSTORE_SLOT_COUNT = 4,
|
|
|
|
+ PWM_CHANNEL_COUNT = 4,
|
|
};
|
|
};
|
|
|
|
|
|
struct vstore_slot {
|
|
struct vstore_slot {
|
|
@@ -71,6 +72,10 @@ struct vstore_slot {
|
|
u8 data[EC_VSTORE_SLOT_SIZE];
|
|
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
|
|
* struct ec_state - Information about the EC state
|
|
*
|
|
*
|
|
@@ -85,6 +90,7 @@ struct vstore_slot {
|
|
* @recovery_req: Keyboard recovery requested
|
|
* @recovery_req: Keyboard recovery requested
|
|
* @test_flags: Flags that control behaviour for tests
|
|
* @test_flags: Flags that control behaviour for tests
|
|
* @slot_locked: Locked vstore slots (mask)
|
|
* @slot_locked: Locked vstore slots (mask)
|
|
|
|
+ * @pwm: Information per PWM channel
|
|
*/
|
|
*/
|
|
struct ec_state {
|
|
struct ec_state {
|
|
u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2];
|
|
u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2];
|
|
@@ -98,6 +104,7 @@ struct ec_state {
|
|
bool recovery_req;
|
|
bool recovery_req;
|
|
uint test_flags;
|
|
uint test_flags;
|
|
struct vstore_slot slot[VSTORE_SLOT_COUNT];
|
|
struct vstore_slot slot[VSTORE_SLOT_COUNT];
|
|
|
|
+ struct ec_pwm_channel pwm[PWM_CHANNEL_COUNT];
|
|
} s_state, *g_state;
|
|
} s_state, *g_state;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -554,6 +561,33 @@ static int process_cmd(struct ec_state *ec,
|
|
len = sizeof(*resp);
|
|
len = sizeof(*resp);
|
|
break;
|
|
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:
|
|
default:
|
|
printf(" ** Unknown EC command %#02x\n", req_hdr->command);
|
|
printf(" ** Unknown EC command %#02x\n", req_hdr->command);
|
|
return -1;
|
|
return -1;
|
|
@@ -619,6 +653,19 @@ void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags)
|
|
ec->test_flags = 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)
|
|
int cros_ec_probe(struct udevice *dev)
|
|
{
|
|
{
|
|
struct ec_state *ec = dev_get_priv(dev);
|
|
struct ec_state *ec = dev_get_priv(dev);
|