0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _LINUX_SCMI_PROTOCOL_H
0009 #define _LINUX_SCMI_PROTOCOL_H
0010
0011 #include <linux/bitfield.h>
0012 #include <linux/device.h>
0013 #include <linux/notifier.h>
0014 #include <linux/types.h>
0015
0016 #define SCMI_MAX_STR_SIZE 64
0017 #define SCMI_SHORT_NAME_MAX_SIZE 16
0018 #define SCMI_MAX_NUM_RATES 16
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct scmi_revision_info {
0035 u16 major_ver;
0036 u16 minor_ver;
0037 u8 num_protocols;
0038 u8 num_agents;
0039 u32 impl_ver;
0040 char vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
0041 char sub_vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
0042 };
0043
0044 struct scmi_clock_info {
0045 char name[SCMI_MAX_STR_SIZE];
0046 unsigned int enable_latency;
0047 bool rate_discrete;
0048 bool rate_changed_notifications;
0049 bool rate_change_requested_notifications;
0050 union {
0051 struct {
0052 int num_rates;
0053 u64 rates[SCMI_MAX_NUM_RATES];
0054 } list;
0055 struct {
0056 u64 min_rate;
0057 u64 max_rate;
0058 u64 step_size;
0059 } range;
0060 };
0061 };
0062
0063 enum scmi_power_scale {
0064 SCMI_POWER_BOGOWATTS,
0065 SCMI_POWER_MILLIWATTS,
0066 SCMI_POWER_MICROWATTS
0067 };
0068
0069 struct scmi_handle;
0070 struct scmi_device;
0071 struct scmi_protocol_handle;
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 struct scmi_clk_proto_ops {
0085 int (*count_get)(const struct scmi_protocol_handle *ph);
0086
0087 const struct scmi_clock_info __must_check *(*info_get)
0088 (const struct scmi_protocol_handle *ph, u32 clk_id);
0089 int (*rate_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
0090 u64 *rate);
0091 int (*rate_set)(const struct scmi_protocol_handle *ph, u32 clk_id,
0092 u64 rate);
0093 int (*enable)(const struct scmi_protocol_handle *ph, u32 clk_id);
0094 int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id);
0095 int (*enable_atomic)(const struct scmi_protocol_handle *ph, u32 clk_id);
0096 int (*disable_atomic)(const struct scmi_protocol_handle *ph,
0097 u32 clk_id);
0098 };
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 struct scmi_perf_proto_ops {
0123 int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain,
0124 u32 max_perf, u32 min_perf);
0125 int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain,
0126 u32 *max_perf, u32 *min_perf);
0127 int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain,
0128 u32 level, bool poll);
0129 int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain,
0130 u32 *level, bool poll);
0131 int (*device_domain_id)(struct device *dev);
0132 int (*transition_latency_get)(const struct scmi_protocol_handle *ph,
0133 struct device *dev);
0134 int (*device_opps_add)(const struct scmi_protocol_handle *ph,
0135 struct device *dev);
0136 int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain,
0137 unsigned long rate, bool poll);
0138 int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain,
0139 unsigned long *rate, bool poll);
0140 int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain,
0141 unsigned long *rate, unsigned long *power);
0142 bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
0143 struct device *dev);
0144 enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
0145 };
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 struct scmi_power_proto_ops {
0157 int (*num_domains_get)(const struct scmi_protocol_handle *ph);
0158 const char *(*name_get)(const struct scmi_protocol_handle *ph,
0159 u32 domain);
0160 #define SCMI_POWER_STATE_TYPE_SHIFT 30
0161 #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)
0162 #define SCMI_POWER_STATE_PARAM(type, id) \
0163 ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
0164 ((id) & SCMI_POWER_STATE_ID_MASK))
0165 #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0)
0166 #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0)
0167 int (*state_set)(const struct scmi_protocol_handle *ph, u32 domain,
0168 u32 state);
0169 int (*state_get)(const struct scmi_protocol_handle *ph, u32 domain,
0170 u32 *state);
0171 };
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182 struct scmi_sensor_reading {
0183 long long value;
0184 unsigned long long timestamp;
0185 };
0186
0187
0188
0189
0190
0191
0192 struct scmi_range_attrs {
0193 long long min_range;
0194 long long max_range;
0195 };
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214 struct scmi_sensor_axis_info {
0215 unsigned int id;
0216 unsigned int type;
0217 int scale;
0218 char name[SCMI_MAX_STR_SIZE];
0219 bool extended_attrs;
0220 unsigned int resolution;
0221 int exponent;
0222 struct scmi_range_attrs attrs;
0223 };
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 struct scmi_sensor_intervals_info {
0241 bool segmented;
0242 unsigned int count;
0243 #define SCMI_SENS_INTVL_SEGMENT_LOW 0
0244 #define SCMI_SENS_INTVL_SEGMENT_HIGH 1
0245 #define SCMI_SENS_INTVL_SEGMENT_STEP 2
0246 unsigned int *desc;
0247 #define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
0248 #define SCMI_SENS_INTVL_GET_EXP(x) \
0249 ({ \
0250 int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
0251 \
0252 if (__signed_exp & BIT(4)) \
0253 __signed_exp |= GENMASK(31, 5); \
0254 __signed_exp; \
0255 })
0256 #define SCMI_MAX_PREALLOC_POOL 16
0257 unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
0258 };
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298 struct scmi_sensor_info {
0299 unsigned int id;
0300 unsigned int type;
0301 int scale;
0302 unsigned int num_trip_points;
0303 bool async;
0304 bool update;
0305 bool timestamped;
0306 int tstamp_scale;
0307 unsigned int num_axis;
0308 struct scmi_sensor_axis_info *axis;
0309 struct scmi_sensor_intervals_info intervals;
0310 unsigned int sensor_config;
0311 #define SCMI_SENS_CFG_UPDATE_SECS_MASK GENMASK(31, 16)
0312 #define SCMI_SENS_CFG_GET_UPDATE_SECS(x) \
0313 FIELD_GET(SCMI_SENS_CFG_UPDATE_SECS_MASK, (x))
0314
0315 #define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11)
0316 #define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \
0317 ({ \
0318 int __signed_exp = \
0319 FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \
0320 \
0321 if (__signed_exp & BIT(4)) \
0322 __signed_exp |= GENMASK(31, 5); \
0323 __signed_exp; \
0324 })
0325
0326 #define SCMI_SENS_CFG_ROUND_MASK GENMASK(10, 9)
0327 #define SCMI_SENS_CFG_ROUND_AUTO 2
0328 #define SCMI_SENS_CFG_ROUND_UP 1
0329 #define SCMI_SENS_CFG_ROUND_DOWN 0
0330
0331 #define SCMI_SENS_CFG_TSTAMP_ENABLED_MASK BIT(1)
0332 #define SCMI_SENS_CFG_TSTAMP_ENABLE 1
0333 #define SCMI_SENS_CFG_TSTAMP_DISABLE 0
0334 #define SCMI_SENS_CFG_IS_TSTAMP_ENABLED(x) \
0335 FIELD_GET(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK, (x))
0336
0337 #define SCMI_SENS_CFG_SENSOR_ENABLED_MASK BIT(0)
0338 #define SCMI_SENS_CFG_SENSOR_ENABLE 1
0339 #define SCMI_SENS_CFG_SENSOR_DISABLE 0
0340 char name[SCMI_MAX_STR_SIZE];
0341 #define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x))
0342 bool extended_scalar_attrs;
0343 unsigned int sensor_power;
0344 unsigned int resolution;
0345 int exponent;
0346 struct scmi_range_attrs scalar_attrs;
0347 };
0348
0349
0350
0351
0352
0353 enum scmi_sensor_class {
0354 NONE = 0x0,
0355 UNSPEC = 0x1,
0356 TEMPERATURE_C = 0x2,
0357 TEMPERATURE_F = 0x3,
0358 TEMPERATURE_K = 0x4,
0359 VOLTAGE = 0x5,
0360 CURRENT = 0x6,
0361 POWER = 0x7,
0362 ENERGY = 0x8,
0363 CHARGE = 0x9,
0364 VOLTAMPERE = 0xA,
0365 NITS = 0xB,
0366 LUMENS = 0xC,
0367 LUX = 0xD,
0368 CANDELAS = 0xE,
0369 KPA = 0xF,
0370 PSI = 0x10,
0371 NEWTON = 0x11,
0372 CFM = 0x12,
0373 RPM = 0x13,
0374 HERTZ = 0x14,
0375 SECS = 0x15,
0376 MINS = 0x16,
0377 HOURS = 0x17,
0378 DAYS = 0x18,
0379 WEEKS = 0x19,
0380 MILS = 0x1A,
0381 INCHES = 0x1B,
0382 FEET = 0x1C,
0383 CUBIC_INCHES = 0x1D,
0384 CUBIC_FEET = 0x1E,
0385 METERS = 0x1F,
0386 CUBIC_CM = 0x20,
0387 CUBIC_METERS = 0x21,
0388 LITERS = 0x22,
0389 FLUID_OUNCES = 0x23,
0390 RADIANS = 0x24,
0391 STERADIANS = 0x25,
0392 REVOLUTIONS = 0x26,
0393 CYCLES = 0x27,
0394 GRAVITIES = 0x28,
0395 OUNCES = 0x29,
0396 POUNDS = 0x2A,
0397 FOOT_POUNDS = 0x2B,
0398 OUNCE_INCHES = 0x2C,
0399 GAUSS = 0x2D,
0400 GILBERTS = 0x2E,
0401 HENRIES = 0x2F,
0402 FARADS = 0x30,
0403 OHMS = 0x31,
0404 SIEMENS = 0x32,
0405 MOLES = 0x33,
0406 BECQUERELS = 0x34,
0407 PPM = 0x35,
0408 DECIBELS = 0x36,
0409 DBA = 0x37,
0410 DBC = 0x38,
0411 GRAYS = 0x39,
0412 SIEVERTS = 0x3A,
0413 COLOR_TEMP_K = 0x3B,
0414 BITS = 0x3C,
0415 BYTES = 0x3D,
0416 WORDS = 0x3E,
0417 DWORDS = 0x3F,
0418 QWORDS = 0x40,
0419 PERCENTAGE = 0x41,
0420 PASCALS = 0x42,
0421 COUNTS = 0x43,
0422 GRAMS = 0x44,
0423 NEWTON_METERS = 0x45,
0424 HITS = 0x46,
0425 MISSES = 0x47,
0426 RETRIES = 0x48,
0427 OVERRUNS = 0x49,
0428 UNDERRUNS = 0x4A,
0429 COLLISIONS = 0x4B,
0430 PACKETS = 0x4C,
0431 MESSAGES = 0x4D,
0432 CHARS = 0x4E,
0433 ERRORS = 0x4F,
0434 CORRECTED_ERRS = 0x50,
0435 UNCORRECTABLE_ERRS = 0x51,
0436 SQ_MILS = 0x52,
0437 SQ_INCHES = 0x53,
0438 SQ_FEET = 0x54,
0439 SQ_CM = 0x55,
0440 SQ_METERS = 0x56,
0441 RADIANS_SEC = 0x57,
0442 BPM = 0x58,
0443 METERS_SEC_SQUARED = 0x59,
0444 METERS_SEC = 0x5A,
0445 CUBIC_METERS_SEC = 0x5B,
0446 MM_MERCURY = 0x5C,
0447 RADIANS_SEC_SQUARED = 0x5D,
0448 OEM_UNIT = 0xFF
0449 };
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467 struct scmi_sensor_proto_ops {
0468 int (*count_get)(const struct scmi_protocol_handle *ph);
0469 const struct scmi_sensor_info __must_check *(*info_get)
0470 (const struct scmi_protocol_handle *ph, u32 sensor_id);
0471 int (*trip_point_config)(const struct scmi_protocol_handle *ph,
0472 u32 sensor_id, u8 trip_id, u64 trip_value);
0473 int (*reading_get)(const struct scmi_protocol_handle *ph, u32 sensor_id,
0474 u64 *value);
0475 int (*reading_get_timestamped)(const struct scmi_protocol_handle *ph,
0476 u32 sensor_id, u8 count,
0477 struct scmi_sensor_reading *readings);
0478 int (*config_get)(const struct scmi_protocol_handle *ph,
0479 u32 sensor_id, u32 *sensor_config);
0480 int (*config_set)(const struct scmi_protocol_handle *ph,
0481 u32 sensor_id, u32 sensor_config);
0482 };
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495 struct scmi_reset_proto_ops {
0496 int (*num_domains_get)(const struct scmi_protocol_handle *ph);
0497 const char *(*name_get)(const struct scmi_protocol_handle *ph,
0498 u32 domain);
0499 int (*latency_get)(const struct scmi_protocol_handle *ph, u32 domain);
0500 int (*reset)(const struct scmi_protocol_handle *ph, u32 domain);
0501 int (*assert)(const struct scmi_protocol_handle *ph, u32 domain);
0502 int (*deassert)(const struct scmi_protocol_handle *ph, u32 domain);
0503 };
0504
0505 enum scmi_voltage_level_mode {
0506 SCMI_VOLTAGE_LEVEL_SET_AUTO,
0507 SCMI_VOLTAGE_LEVEL_SET_SYNC,
0508 };
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529 struct scmi_voltage_info {
0530 unsigned int id;
0531 bool segmented;
0532 bool negative_volts_allowed;
0533 bool async_level_set;
0534 char name[SCMI_MAX_STR_SIZE];
0535 unsigned int num_levels;
0536 #define SCMI_VOLTAGE_SEGMENT_LOW 0
0537 #define SCMI_VOLTAGE_SEGMENT_HIGH 1
0538 #define SCMI_VOLTAGE_SEGMENT_STEP 2
0539 int *levels_uv;
0540 };
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553 struct scmi_voltage_proto_ops {
0554 int (*num_domains_get)(const struct scmi_protocol_handle *ph);
0555 const struct scmi_voltage_info __must_check *(*info_get)
0556 (const struct scmi_protocol_handle *ph, u32 domain_id);
0557 int (*config_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
0558 u32 config);
0559 #define SCMI_VOLTAGE_ARCH_STATE_OFF 0x0
0560 #define SCMI_VOLTAGE_ARCH_STATE_ON 0x7
0561 int (*config_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
0562 u32 *config);
0563 int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
0564 enum scmi_voltage_level_mode mode, s32 volt_uV);
0565 int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
0566 s32 *volt_uV);
0567 };
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600 struct scmi_powercap_info {
0601 unsigned int id;
0602 bool notify_powercap_cap_change;
0603 bool notify_powercap_measurement_change;
0604 bool async_powercap_cap_set;
0605 bool powercap_cap_config;
0606 bool powercap_monitoring;
0607 bool powercap_pai_config;
0608 bool powercap_scale_mw;
0609 bool powercap_scale_uw;
0610 bool fastchannels;
0611 char name[SCMI_MAX_STR_SIZE];
0612 unsigned int min_pai;
0613 unsigned int max_pai;
0614 unsigned int pai_step;
0615 unsigned int min_power_cap;
0616 unsigned int max_power_cap;
0617 unsigned int power_cap_step;
0618 unsigned int sustainable_power;
0619 unsigned int accuracy;
0620 #define SCMI_POWERCAP_ROOT_ZONE_ID 0xFFFFFFFFUL
0621 unsigned int parent_id;
0622 struct scmi_fc_info *fc_info;
0623 };
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657 struct scmi_powercap_proto_ops {
0658 int (*num_domains_get)(const struct scmi_protocol_handle *ph);
0659 const struct scmi_powercap_info __must_check *(*info_get)
0660 (const struct scmi_protocol_handle *ph, u32 domain_id);
0661 int (*cap_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
0662 u32 *power_cap);
0663 int (*cap_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
0664 u32 power_cap, bool ignore_dresp);
0665 int (*pai_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
0666 u32 *pai);
0667 int (*pai_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
0668 u32 pai);
0669 int (*measurements_get)(const struct scmi_protocol_handle *ph,
0670 u32 domain_id, u32 *average_power, u32 *pai);
0671 int (*measurements_threshold_set)(const struct scmi_protocol_handle *ph,
0672 u32 domain_id, u32 power_thresh_low,
0673 u32 power_thresh_high);
0674 int (*measurements_threshold_get)(const struct scmi_protocol_handle *ph,
0675 u32 domain_id, u32 *power_thresh_low,
0676 u32 *power_thresh_high);
0677 };
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719 struct scmi_notify_ops {
0720 int (*devm_event_notifier_register)(struct scmi_device *sdev,
0721 u8 proto_id, u8 evt_id,
0722 const u32 *src_id,
0723 struct notifier_block *nb);
0724 int (*devm_event_notifier_unregister)(struct scmi_device *sdev,
0725 u8 proto_id, u8 evt_id,
0726 const u32 *src_id,
0727 struct notifier_block *nb);
0728 int (*event_notifier_register)(const struct scmi_handle *handle,
0729 u8 proto_id, u8 evt_id,
0730 const u32 *src_id,
0731 struct notifier_block *nb);
0732 int (*event_notifier_unregister)(const struct scmi_handle *handle,
0733 u8 proto_id, u8 evt_id,
0734 const u32 *src_id,
0735 struct notifier_block *nb);
0736 };
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760 struct scmi_handle {
0761 struct device *dev;
0762 struct scmi_revision_info *version;
0763
0764 int __must_check (*devm_protocol_acquire)(struct scmi_device *sdev,
0765 u8 proto);
0766 const void __must_check *
0767 (*devm_protocol_get)(struct scmi_device *sdev, u8 proto,
0768 struct scmi_protocol_handle **ph);
0769 void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
0770 bool (*is_transport_atomic)(const struct scmi_handle *handle,
0771 unsigned int *atomic_threshold);
0772
0773 const struct scmi_notify_ops *notify_ops;
0774 };
0775
0776 enum scmi_std_protocol {
0777 SCMI_PROTOCOL_BASE = 0x10,
0778 SCMI_PROTOCOL_POWER = 0x11,
0779 SCMI_PROTOCOL_SYSTEM = 0x12,
0780 SCMI_PROTOCOL_PERF = 0x13,
0781 SCMI_PROTOCOL_CLOCK = 0x14,
0782 SCMI_PROTOCOL_SENSOR = 0x15,
0783 SCMI_PROTOCOL_RESET = 0x16,
0784 SCMI_PROTOCOL_VOLTAGE = 0x17,
0785 SCMI_PROTOCOL_POWERCAP = 0x18,
0786 };
0787
0788 enum scmi_system_events {
0789 SCMI_SYSTEM_SHUTDOWN,
0790 SCMI_SYSTEM_COLDRESET,
0791 SCMI_SYSTEM_WARMRESET,
0792 SCMI_SYSTEM_POWERUP,
0793 SCMI_SYSTEM_SUSPEND,
0794 SCMI_SYSTEM_MAX
0795 };
0796
0797 struct scmi_device {
0798 u32 id;
0799 u8 protocol_id;
0800 const char *name;
0801 struct device dev;
0802 struct scmi_handle *handle;
0803 };
0804
0805 #define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
0806
0807 struct scmi_device *
0808 scmi_device_create(struct device_node *np, struct device *parent, int protocol,
0809 const char *name);
0810 void scmi_device_destroy(struct scmi_device *scmi_dev);
0811
0812 struct scmi_device_id {
0813 u8 protocol_id;
0814 const char *name;
0815 };
0816
0817 struct scmi_driver {
0818 const char *name;
0819 int (*probe)(struct scmi_device *sdev);
0820 void (*remove)(struct scmi_device *sdev);
0821 const struct scmi_device_id *id_table;
0822
0823 struct device_driver driver;
0824 };
0825
0826 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
0827
0828 #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
0829 int scmi_driver_register(struct scmi_driver *driver,
0830 struct module *owner, const char *mod_name);
0831 void scmi_driver_unregister(struct scmi_driver *driver);
0832 #else
0833 static inline int
0834 scmi_driver_register(struct scmi_driver *driver, struct module *owner,
0835 const char *mod_name)
0836 {
0837 return -EINVAL;
0838 }
0839
0840 static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
0841 #endif
0842
0843 #define scmi_register(driver) \
0844 scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
0845 #define scmi_unregister(driver) \
0846 scmi_driver_unregister(driver)
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856 #define module_scmi_driver(__scmi_driver) \
0857 module_driver(__scmi_driver, scmi_register, scmi_unregister)
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867 #define module_scmi_protocol(__scmi_protocol) \
0868 module_driver(__scmi_protocol, \
0869 scmi_protocol_register, scmi_protocol_unregister)
0870
0871 struct scmi_protocol;
0872 int scmi_protocol_register(const struct scmi_protocol *proto);
0873 void scmi_protocol_unregister(const struct scmi_protocol *proto);
0874
0875
0876 enum scmi_notification_events {
0877 SCMI_EVENT_POWER_STATE_CHANGED = 0x0,
0878 SCMI_EVENT_CLOCK_RATE_CHANGED = 0x0,
0879 SCMI_EVENT_CLOCK_RATE_CHANGE_REQUESTED = 0x1,
0880 SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
0881 SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
0882 SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
0883 SCMI_EVENT_SENSOR_UPDATE = 0x1,
0884 SCMI_EVENT_RESET_ISSUED = 0x0,
0885 SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
0886 SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
0887 SCMI_EVENT_POWERCAP_CAP_CHANGED = 0x0,
0888 SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED = 0x1,
0889 };
0890
0891 struct scmi_power_state_changed_report {
0892 ktime_t timestamp;
0893 unsigned int agent_id;
0894 unsigned int domain_id;
0895 unsigned int power_state;
0896 };
0897
0898 struct scmi_clock_rate_notif_report {
0899 ktime_t timestamp;
0900 unsigned int agent_id;
0901 unsigned int clock_id;
0902 unsigned long long rate;
0903 };
0904
0905 struct scmi_system_power_state_notifier_report {
0906 ktime_t timestamp;
0907 unsigned int agent_id;
0908 #define SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(flags) ((flags) & BIT(0))
0909 unsigned int flags;
0910 unsigned int system_state;
0911 unsigned int timeout;
0912 };
0913
0914 struct scmi_perf_limits_report {
0915 ktime_t timestamp;
0916 unsigned int agent_id;
0917 unsigned int domain_id;
0918 unsigned int range_max;
0919 unsigned int range_min;
0920 };
0921
0922 struct scmi_perf_level_report {
0923 ktime_t timestamp;
0924 unsigned int agent_id;
0925 unsigned int domain_id;
0926 unsigned int performance_level;
0927 };
0928
0929 struct scmi_sensor_trip_point_report {
0930 ktime_t timestamp;
0931 unsigned int agent_id;
0932 unsigned int sensor_id;
0933 unsigned int trip_point_desc;
0934 };
0935
0936 struct scmi_sensor_update_report {
0937 ktime_t timestamp;
0938 unsigned int agent_id;
0939 unsigned int sensor_id;
0940 unsigned int readings_count;
0941 struct scmi_sensor_reading readings[];
0942 };
0943
0944 struct scmi_reset_issued_report {
0945 ktime_t timestamp;
0946 unsigned int agent_id;
0947 unsigned int domain_id;
0948 unsigned int reset_state;
0949 };
0950
0951 struct scmi_base_error_report {
0952 ktime_t timestamp;
0953 unsigned int agent_id;
0954 bool fatal;
0955 unsigned int cmd_count;
0956 unsigned long long reports[];
0957 };
0958
0959 struct scmi_powercap_cap_changed_report {
0960 ktime_t timestamp;
0961 unsigned int agent_id;
0962 unsigned int domain_id;
0963 unsigned int power_cap;
0964 unsigned int pai;
0965 };
0966
0967 struct scmi_powercap_meas_changed_report {
0968 ktime_t timestamp;
0969 unsigned int agent_id;
0970 unsigned int domain_id;
0971 unsigned int power;
0972 };
0973 #endif