t/cssIL*R nux.n/drnewrs/acpi/sbshc.ccript">t/cssIg="e/n"> g="ebody class="fk]." = 0; /script> { vclass="n"> iimage/pngpt> { vclass="n"> iimtopuncs { > e/pngpt>spuesclass="dec_t/cssage >spuesclass="dec_logouncaesheet" h"IL*R< <' /spuege >spuesid="currd_f_pd='age pt>aesheet" hinux.no/linux+v3nux.n/< <' aesheet"drnewrs/">drnewrs/< <' aesheet"drnewrs/acpi/">acpi/< <' aesheet"drnewrs/acpi/sbshc.c">sbshc.c< <'e >/spuege >!-- --ge/pngptpt>spuesid="dec_pri_fre/pngptpt /s pt>/x-w a; ;}f="+pri_f=drnewrs/acpi/sbshc.c"rgs[0]; "r.se"sid="pri_f_/x-wage pt="ebutt}fuscriptsubmie"sclass="pri_frge/pngpt ngptpt>imgscript" src="../.statpri_ffavicoalt="Pri_frge/pngptngptpt>/butt}f/s pt>//x-wge/pngptpt>/spuege/pngptpt>spuesid="dec_savere/pngptpt /s pt>/x-w a; ;}f="+save=drnewrs/acpi/sbshc.c"rgs[0]; "r.se"sid="save_/x-wage pt="ebutt}fuscriptsubmie"sclass="saverge/pngpt ngptpt>imgscript" src="../.statsavefavicoalt="Saverge/pngptngptpt>/butt}f/s pt>//x-wge/pngptpt>/spuege/pngpt>/spuege e/pngpt> { vclass="dec_ad_uage >spuesclass="dec_ewrs;}fage pt>aee pt="esheet" hinux.no/lin/drnewrs/acpi/sbshc.cage pt="eimgscript" src="../.statlefffavicoalt="<<uncsa/s pt>/x-w a; ;}f="drnewrs/acpi/sbshc.c"rgs[0]; "cumage pt="espuesid="ewr_ent[i]age pt="="esnt[i]nt wi="e"sid="e"s ondystat="upy(te_ewrs;}f].appl ' href="http://lxr.linux.no/linux+'l 'nux.n'l ''l 'drnewrs/acpi/sbshc.c');rge/pg="eop ;}fu { div"v4.10"e ptge/pv4.10 e pt="e/spafge ="e/formge ="ea e pt=" href="../linux+v3.6.2/drivers/acpi/sbshc.c">e pt="eimg src="../.static/gfx/right.png" alt=">>">e e/spafgee espaf class="lxr_search">e pt
e pt="einput typiv"hidden" namiv"navtarget" { div"">e pt="einput typiv"text" namiv"search" idv"search">e pt="ebutt}futypiv"submit">Searche pt="Prefse ="e/a>e e/spafgept=" "e/divgept=" "eform ac ;}f="ajax+*" method="post" onsubmit="return false;">e einput typiv"hidden" namiv"ajax_lookup" idv"ajax_lookup" { div"">ept=" "e/formgeept=" "ediv class="headingbott}m">e ediv idv"file_contents"g
" "1e/a>espaf class="comment">/*e/spafge" "2e/a>espaf class="comment"> * SMBus driver for ACPI Embedded Controller (v0.1)e/spafge" "3e/a>espaf class="comment"> *e/spafge" "4e/a>espaf class="comment"> * Copyright (c) 2007 Alexey Starikovskiye/spafge" "5e/a>espaf class="comment"> *e/spafge" "6e/a>espaf class="comment"> * This program is free software; you caf redistribute it and/or modifye/spafge" "7e/a>espaf class="comment"> * it under the terms of the GNU General Public License as published bye/spafge" "8e/a>espaf class="comment"> * the Free Software Founda ;}fu ers;}fu2.e/spafge" "9e/a>espaf class="comment"> */e/spafge" 10" 11e/a>#include <acpi/acpi_bus.he/a>>e" 12e/a>#include <acpi/acpi_drivers.he/a>>e" 13e/a>#include <linux/wait.he/a>>e" 14e/a>#include <linux/slab.he/a>>e" 15e/a>#include <linux/delay.he/a>>e" 16e/a>#include <linux/module.he/a>>e" 17e/a>#include <linux/interrupt.he/a>>e" 18e/a>#include "sbshc.he/a>"e" 19" 20PREFIX"ACPI: "" 21" 22ACPI_SMB_HC_CLASS"smbus_host_ctl"" 23ACPI_SMB_HC_DEVICE_NAME"ACPI SMBus HC"" 24" 25e/a>struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hc" 26acpi_ecec" 27mutexlock" 28wait_queue_head_twait" 29u8offset" 30u8query_bit" 31smbus_alarm_callbackcallback" 32context" 33" 34" 35e/a>static int"ea href="+code=acpi_smbus_hc_add" class="sref">acpi_smbus_hc_adde/a>(struct"ea href="+code=acpi_device" class="sref">acpi_devicedevice" 36e/a>static int"ea href="+code=acpi_smbus_hc_remove" class="sref">acpi_smbus_hc_removee/a>(struct"ea href="+code=acpi_device" class="sref">acpi_devicedevicetypi" 37" 38e/a>static const struct"ea href="+code=acpi_device_id" class="sref">acpi_device_idsbs_device_ids" 39"ACPI0001"" 40"ACPI0005"" 41""" 42" 43" 44e/a>ea href="+code=MODULE_DEVICE_TABLE" class="sref">MODULE_DEVICE_TABLEe/a>(ea href="+code=acpi" class="sref">acpisbs_device_ids" 45" 46e/a>static struct"ea href="+code=acpi_driver" class="sref">acpi_driveracpi_smb_hc_driver" 47nami"smbus_hc"" 48classACPI_SMB_HC_CLASS" 49idssbs_device_ids" 50ops" 51adde/a> = ea href="+code=acpi_smbus_hc_add" class="sref">acpi_smbus_hc_adde/a>,e" 52removee/a> = ea href="+code=acpi_smbus_hc_remove" class="sref">acpi_smbus_hc_removee/a>,e" 53" 54" 55" 56e/a>un;}fuea href="+code=acpi_smb_status" class="sref">acpi_smb_status" 57u8raw" 58" 59u8status" 60u8reserved" 61u8alarm" 62u8done" 63fields" 64" 65" 66e/a>enumuea href="+code=acpi_smb_status_codes" class="sref">acpi_smb_status_codes" 67SMBUS_OKe/a> = 0,e" 68SMBUS_UNKNOWN_FAILUREe/a> = 0x07,e" 69SMBUS_DEVICE_ADDRESS_NACKe/a> = 0x10,e" 70SMBUS_DEVICE_ERRORe/a> = 0x11,e" 71SMBUS_DEVICE_COMMAND_ACCESS_DENIEDe/a> = 0x12,e" 72SMBUS_UNKNOWN_ERRORe/a> = 0x13,e" 73SMBUS_DEVICE_ACCESS_DENIEDe/a> = 0x17,e" 74SMBUS_TIMEOUTe/a> = 0x18,e" 75SMBUS_HOST_UNSUPPORTED_PROTOCOLe/a> = 0x19,e" 76SMBUS_BUSYe/a> = 0x1a,e" 77SMBUS_PEC_ERRORe/a> = 0x1f,e" 78" 79" 80e/a>enumuea href="+code=acpi_smb_offset" class="sref">acpi_smb_offset" 81ACPI_SMB_PROTOCOLe/a> = 0, "espaf class="comment">/* protocol, PEC */e/spafge" 82ACPI_SMB_STATUSe/a> = 1," " espaf class="comment">/* status */e/spafge" 83ACPI_SMB_ADDRESSe/a> = 2, " espaf class="comment">/* address */e/spafge" 84ACPI_SMB_COMMANDe/a> = 3, " espaf class="comment">/* command */e/spafge" 85ACPI_SMB_DATAe/a> = 4,t=" " espaf class="comment">/* 32 data registers */e/spafge" 86ACPI_SMB_BLOCK_COUNTe/a> = 0x24," " espaf class="comment">/* number of data bytes */e/spafge" 87ACPI_SMB_ALARM_ADDRESSe/a> = 0x25, "espaf class="comment">/* alarm address */e/spafge" 88ACPI_SMB_ALARM_DATAe/a> = 0x26,=" " espaf class="comment">/* 2 bytes alarm data */e/spafge" 89" 90" 91e/a>static ea href="+code=inline" class="sref">inlinee/a> int"ea href="+code=smb_hc_read" class="sref">smb_hc_reade/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchcu8addressu8data" 92" 93ec_reade/a>(ea href="+code=hc" class="sref">hcoffsetaddressdata" 94" 95" 96e/a>static ea href="+code=inline" class="sref">inlinee/a> int"ea href="+code=smb_hc_write" class="sref">smb_hc_writee/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchcu8addressu8data" 97" 98ec_writee/a>(ea href="+code=hc" class="sref">hcoffsetaddressdata" 99"100"101e/a>static ea href="+code=inline" class="sref">inlinee/a> int"ea href="+code=smb_check_done" class="sref">smb_check_donee/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchc"102"103acpi_smb_statusstatusraw"104smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_STATUSe/a>, &ea href="+code=status" class="sref">statusraw"105statusfieldsdonestatusfieldsstatusSMBUS_OKe/a>);e"106"107"108e/a>static int"ea href="+code=wait_transac ;}f_complete" class="sref">wait_transac ;}f_completee/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchctimeout"109"110wait_event_timeoute/a>(ea href="+code=hc" class="sref">hcwaitsmb_check_donee/a>(ea href="+code=hc" class="sref">hc"111msecs_to_jiffiese/a>(ea href="+code=timeout" class="sref">timeout"112"113/*e/spafge"114e/a>espaf class="comment">         * After the timeout happens, OS will try to check the status of SMbus.e/spafge"115e/a>espaf class="comment">         * If the status is what OS expected, it will be regarded as the bogus"116e/a>espaf class="comment">         * timeout.e/spafge"117e/a>espaf class="comment">         */e/spafge"118smb_check_donee/a>(ea href="+code=hc" class="sref">hc"119"120"121ETIME"122"123"124acpi_smbus_transac ;}fe/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchcu8protocol"125u8addressu8commandu8datau8length"126"127retEFAULTi"128u8tempsz"129"130hc"131printke/a>(ea href="+code=KERN_ERR" class="sref">KERN_ERRPREFIX"host controller is not configured\n""132ret"133"134"135mutex_locke/a>(&ea href="+code=hc" class="sref">hclock"136smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_PROTOCOLe/a>, &ea href="+code=temp" class="sref">temp"137end"138temp"139retEBUSYe/a>;e"140end"141"142smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_COMMANDe/a>, ea href="+code=command" class="sref">command"143protocol"144smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_BLOCK_COUNTe/a>, ea href="+code=length" class="sref">length"145iilengthi"146smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_DATAe/a> + ea href="+code=i" class="sref">idatai"147"148smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_ADDRESSe/a>, ea href="+code=address" class="sref">address"149smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_PROTOCOLe/a>, ea href="+code=protocol" class="sref">protocol"150/*e/spafge"151e/a>espaf class="comment">  pt=" " * Wait for completion. Save the status code, data size,e/spafge"152e/a>espaf class="comment">  pt=" " * and data into the return package (if required by the protocol).e/spafge"153e/a>espaf class="comment">  pt=" " */e/spafge"154retwait_transac ;}f_completee/a>(ea href="+code=hc" class="sref">hc"155retprotocol"156end"157protocol"158SMBUS_RECEIVE_BYTE"159SMBUS_READ_BYTE"160sz"161"162SMBUS_READ_WORD"163sz"164"165SMBUS_READ_BLOCK"166smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_BLOCK_COUNTe/a>, &ea href="+code=sz" class="sref">sz"167retEFAULT"168end"169"170sz"171"172"173iiszi"174smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_DATAe/a> + ea href="+code=i" class="sref">idatai"175end"176mutex_unlocke/a>(&ea href="+code=hc" class="sref">hclock"177ret"178"179"180e/a>int"ea href="+code=acpi_smbus_read" class="sref">acpi_smbus_reade/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchcu8protocolu8address"181u8commandu8data"182"183acpi_smbus_transac ;}fe/a>(ea href="+code=hc" class="sref">hcprotocoladdresscommanddata"184"185"186EXPORT_SYMBOL_GPLe/a>(ea href="+code=acpi_smbus_read" class="sref">acpi_smbus_reade/a>);e"187"188acpi_smbus_writee/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchcu8protocolu8address"189u8commandu8datau8length"190"191acpi_smbus_transac ;}fe/a>(ea href="+code=hc" class="sref">hcprotocoladdresscommanddatalength"192"193"194e/a>ea href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPLe/a>(ea href="+code=acpi_smbus_write" class="sref">acpi_smbus_writee/a>);e"195"196e/a>int"ea href="+code=acpi_smbus_register_callback" class="sref">acpi_smbus_register_callbacke/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchc"197smbus_alarm_callbackcallbackcontext"198"199mutex_locke/a>(&ea href="+code=hc" class="sref">hclock"200hccallbackcallback"201hccontextcontext"202mutex_unlocke/a>(&ea href="+code=hc" class="sref">hclock"203"204"205"206EXPORT_SYMBOL_GPLe/a>(ea href="+code=acpi_smbus_register_callback" class="sref">acpi_smbus_register_callbacke/a>);e"207"208acpi_smbus_unregister_callbacke/a>(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hchc"209"210mutex_locke/a>(&ea href="+code=hc" class="sref">hclock"211hccallbackNULL"212hccontextNULL"213mutex_unlocke/a>(&ea href="+code=hc" class="sref">hclock"214"215e/a>}e"216e/a>e"217e/a>ea href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPLe/a>(ea href="+code=acpi_smbus_unregister_callback" class="sref">acpi_smbus_unregister_callbacke/a>);e"218"219inlinee/a> void ea href="+code=acpi_smbus_callback" class="sref">acpi_smbus_callbacke/a>(void *ea href="+code=context" class="sref">context"220"221acpi_smb_hchccontext"222hccallback"223hccallbackhccontext"224"225"226e/a>static int"ea href="+code=smbus_alarm" class="sref">smbus_alarme/a>(void *ea href="+code=context" class="sref">context"227"228acpi_smb_hchccontext"229acpi_smb_statusstatus"230u8address"231smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_STATUSe/a>, &ea href="+code=status" class="sref">statusraw"232"233/* Check if it is only a completion notify */e/spafge"234statusfieldsdone"235wake_upe/a>(&ea href="+code=hc" class="sref">hcwait"236statusfieldsalarm"237"238mutex_locke/a>(&ea href="+code=hc" class="sref">hclock"239smb_hc_reade/a>(ea href="+code=hc" class="sref">hcACPI_SMB_ALARM_ADDRESSe/a>, &ea href="+code=address" class="sref">address"240statusfieldsalarm"241smb_hc_writee/a>(ea href="+code=hc" class="sref">hcACPI_SMB_STATUSe/a>, ea href="+code=status" class="sref">statusraw"242/* We are only interested in events coming from known devices */e/spafge"243address"244ACPI_SBS_CHARGER"245ACPI_SBS_MANAGER"246ACPI_SBS_BATTERY"247acpi_os_executee/a>(ea href="+code=OSL_NOTIFY_HANDLER" class="sref">OSL_NOTIFY_HANDLERe/a>,e"248acpi_smbus_callbacke/a>, ea href="+code=hc" class="sref">hc"249"250"251mutex_unlocke/a>(&ea href="+code=hc" class="sref">hclock"252"253e/a>}e"254"255acpi_ec_query_funcdata"256e/a>e"257acpi_ec_add_query_handlere/a>(struct"ea href="+code=acpi_ec" class="sref">acpi_ececu8query_bite/a>,e"258acpi_handlehandleacpi_ec_query_funcfunc"259data"260"261e/a>static int"ea href="+code=acpi_smbus_hc_add" class="sref">acpi_smbus_hc_adde/a>(struct"ea href="+code=acpi_device" class="sref">acpi_devicedevice"262"263status"264val"265acpi_smb_hchc"266e/a>e"267device"268EINVAL"269"270statusacpi_evaluate_integere/a>(ea href="+code=device" class="sref">devicehandle"_EC"NULLval"271ACPI_FAILUREe/a>(ea href="+code=status" class="sref">status"272printke/a>(ea href="+code=KERN_ERR" class="sref">KERN_ERRPREFIX"error obtaining _EC.\n""273EIO"274"275"276strcpye/a>(ea href="+code=acpi_device_nami" class="sref">acpi_device_namie/a>(ea href="+code=device" class="sref">deviceACPI_SMB_HC_DEVICE_NAME"277strcpye/a>(ea href="+code=acpi_device_class" class="sref">acpi_device_classe/a>(ea href="+code=device" class="sref">deviceACPI_SMB_HC_CLASS"278"279hckzalloce/a>(sizeof(struct"ea href="+code=acpi_smb_hc" class="sref">acpi_smb_hcGFP_KERNEL"280hc"281ENOMEM"282mutex_inite/a>(&ea href="+code=hc" class="sref">hclock"283init_waitqueue_heade/a>(&ea href="+code=hc" class="sref">hcwait"284"285hcecacpi_driver_datae/a>(ea href="+code=device" class="sref">deviceparent"286hcoffsetval"287hcquery_bite/a> = ea href="+code=val" class="sref">val"288devicedriver_datae/a> = ea href="+code=hc" class="sref">hc"289"290acpi_ec_add_query_handlere/a>(ea href="+code=hc" class="sref">hcechcquery_bite/a>, ea href="+code=NULL" class="sref">NULLsmbus_alarme/a>, ea href="+code=hc" class="sref">hc"291printke/a>(ea href="+code=KERN_INFO" class="sref">KERN_INFOPREFIX"SBS HC: EC = 0x%p, offset = 0x%0x, query_bit = 0x%0x\n""292hcechcoffsethcquery_bite/a>);e"293"294"295e/a>}e"296e/a>e"297acpi_ec_remove_query_handlere/a>(struct"ea href="+code=acpi_ec" class="sref">acpi_ececu8query_bite/a>);e"298"299acpi_smbus_hc_removee/a>(struct"ea href="+code=acpi_device" class="sref">acpi_devicedevicetype"300"301acpi_smb_hchc"302"303device"304EINVAL"305"306hcacpi_driver_datae/a>(ea href="+code=device" class="sref">device"307acpi_ec_remove_query_handlere/a>(ea href="+code=hc" class="sref">hcechcquery_bite/a>);e"308kfreee/a>(ea href="+code=hc" class="sref">hc"309devicedriver_datae/a> = ea href="+code=NULL" class="sref">NULL"310"311"312"313__inite/a>"ea href="+code=acpi_smb_hc_init" class="sref">acpi_smb_hc_inite/a>(void)e"314"315result"316e/a>e"317resultacpi_bus_register_drivere/a>(&ea href="+code=acpi_smb_hc_driver" class="sref">acpi_smb_hc_driver"318result"319ENODEV"320"321"322"323__exite/a>"ea href="+code=acpi_smb_hc_exit" class="sref">acpi_smb_hc_exite/a>(void)e"324"325acpi_bus_unregister_drivere/a>(&ea href="+code=acpi_smb_hc_driver" class="sref">acpi_smb_hc_driver"326e/a>}e"327"328module_inite/a>(ea href="+code=acpi_smb_hc_init" class="sref">acpi_smb_hc_inite/a>);e"329module_exite/a>(ea href="+code=acpi_smb_hc_exit" class="sref">acpi_smb_hc_exite/a>);e"330"331MODULE_LICENSEe/a>(espaf class="string">"GPL""332MODULE_AUTHORe/a>(espaf class="string">"Alexey Starikovskiy""333MODULE_DESCRIPTIONe/a>(espaf class="string">"ACPI SMBus HC driver""334