18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * dcdbas.h: Definitions for Dell Systems Management Base driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1995-2005 Dell Inc. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _DCDBAS_H_ 98c2ecf20Sopenharmony_ci#define _DCDBAS_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/device.h> 128c2ecf20Sopenharmony_ci#include <linux/sysfs.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define MAX_SMI_DATA_BUF_SIZE (256 * 1024) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define HC_ACTION_NONE (0) 188c2ecf20Sopenharmony_ci#define HC_ACTION_HOST_CONTROL_POWEROFF BIT(1) 198c2ecf20Sopenharmony_ci#define HC_ACTION_HOST_CONTROL_POWERCYCLE BIT(2) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define HC_SMITYPE_NONE (0) 228c2ecf20Sopenharmony_ci#define HC_SMITYPE_TYPE1 (1) 238c2ecf20Sopenharmony_ci#define HC_SMITYPE_TYPE2 (2) 248c2ecf20Sopenharmony_ci#define HC_SMITYPE_TYPE3 (3) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define ESM_APM_CMD (0x0A0) 278c2ecf20Sopenharmony_ci#define ESM_APM_POWER_CYCLE (0x10) 288c2ecf20Sopenharmony_ci#define ESM_STATUS_CMD_UNSUCCESSFUL (-1) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define CMOS_BASE_PORT (0x070) 318c2ecf20Sopenharmony_ci#define CMOS_PAGE1_INDEX_PORT (0) 328c2ecf20Sopenharmony_ci#define CMOS_PAGE1_DATA_PORT (1) 338c2ecf20Sopenharmony_ci#define CMOS_PAGE2_INDEX_PORT_PIIX4 (2) 348c2ecf20Sopenharmony_ci#define CMOS_PAGE2_DATA_PORT_PIIX4 (3) 358c2ecf20Sopenharmony_ci#define PE1400_APM_CONTROL_PORT (0x0B0) 368c2ecf20Sopenharmony_ci#define PCAT_APM_CONTROL_PORT (0x0B2) 378c2ecf20Sopenharmony_ci#define PCAT_APM_STATUS_PORT (0x0B3) 388c2ecf20Sopenharmony_ci#define PE1300_CMOS_CMD_STRUCT_PTR (0x38) 398c2ecf20Sopenharmony_ci#define PE1400_CMOS_CMD_STRUCT_PTR (0x70) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define MAX_SYSMGMT_SHORTCMD_PARMBUF_LEN (14) 428c2ecf20Sopenharmony_ci#define MAX_SYSMGMT_LONGCMD_SGENTRY_NUM (16) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define TIMEOUT_USEC_SHORT_SEMA_BLOCKING (10000) 458c2ecf20Sopenharmony_ci#define EXPIRED_TIMER (0) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define SMI_CMD_MAGIC (0x534D4931) 488c2ecf20Sopenharmony_ci#define SMM_EPS_SIG "$SCB" 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define DCDBAS_DEV_ATTR_RW(_name) \ 518c2ecf20Sopenharmony_ci DEVICE_ATTR(_name,0600,_name##_show,_name##_store); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define DCDBAS_DEV_ATTR_RO(_name) \ 548c2ecf20Sopenharmony_ci DEVICE_ATTR(_name,0400,_name##_show,NULL); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define DCDBAS_DEV_ATTR_WO(_name) \ 578c2ecf20Sopenharmony_ci DEVICE_ATTR(_name,0200,NULL,_name##_store); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define DCDBAS_BIN_ATTR_RW(_name) \ 608c2ecf20Sopenharmony_cistruct bin_attribute bin_attr_##_name = { \ 618c2ecf20Sopenharmony_ci .attr = { .name = __stringify(_name), \ 628c2ecf20Sopenharmony_ci .mode = 0600 }, \ 638c2ecf20Sopenharmony_ci .read = _name##_read, \ 648c2ecf20Sopenharmony_ci .write = _name##_write, \ 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistruct smi_cmd { 688c2ecf20Sopenharmony_ci __u32 magic; 698c2ecf20Sopenharmony_ci __u32 ebx; 708c2ecf20Sopenharmony_ci __u32 ecx; 718c2ecf20Sopenharmony_ci __u16 command_address; 728c2ecf20Sopenharmony_ci __u8 command_code; 738c2ecf20Sopenharmony_ci __u8 reserved; 748c2ecf20Sopenharmony_ci __u8 command_buffer[1]; 758c2ecf20Sopenharmony_ci} __attribute__ ((packed)); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistruct apm_cmd { 788c2ecf20Sopenharmony_ci __u8 command; 798c2ecf20Sopenharmony_ci __s8 status; 808c2ecf20Sopenharmony_ci __u16 reserved; 818c2ecf20Sopenharmony_ci union { 828c2ecf20Sopenharmony_ci struct { 838c2ecf20Sopenharmony_ci __u8 parm[MAX_SYSMGMT_SHORTCMD_PARMBUF_LEN]; 848c2ecf20Sopenharmony_ci } __attribute__ ((packed)) shortreq; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci struct { 878c2ecf20Sopenharmony_ci __u16 num_sg_entries; 888c2ecf20Sopenharmony_ci struct { 898c2ecf20Sopenharmony_ci __u32 size; 908c2ecf20Sopenharmony_ci __u64 addr; 918c2ecf20Sopenharmony_ci } __attribute__ ((packed)) 928c2ecf20Sopenharmony_ci sglist[MAX_SYSMGMT_LONGCMD_SGENTRY_NUM]; 938c2ecf20Sopenharmony_ci } __attribute__ ((packed)) longreq; 948c2ecf20Sopenharmony_ci } __attribute__ ((packed)) parameters; 958c2ecf20Sopenharmony_ci} __attribute__ ((packed)); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciint dcdbas_smi_request(struct smi_cmd *smi_cmd); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct smm_eps_table { 1008c2ecf20Sopenharmony_ci char smm_comm_buff_anchor[4]; 1018c2ecf20Sopenharmony_ci u8 length; 1028c2ecf20Sopenharmony_ci u8 checksum; 1038c2ecf20Sopenharmony_ci u8 version; 1048c2ecf20Sopenharmony_ci u64 smm_comm_buff_addr; 1058c2ecf20Sopenharmony_ci u64 num_of_4k_pages; 1068c2ecf20Sopenharmony_ci} __packed; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#endif /* _DCDBAS_H_ */ 1098c2ecf20Sopenharmony_ci 110