12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281 |
- // SPDX-License-Identifier: GPL-2.0+
- /*
- * Texas Instruments System Control Interface Protocol Driver
- * Based on drivers/firmware/ti_sci.c from Linux.
- *
- * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
- * Lokesh Vutla <lokeshvutla@ti.com>
- */
- #include <common.h>
- #include <dm.h>
- #include <errno.h>
- #include <log.h>
- #include <mailbox.h>
- #include <malloc.h>
- #include <dm/device.h>
- #include <dm/device_compat.h>
- #include <dm/devres.h>
- #include <linux/bitops.h>
- #include <linux/compat.h>
- #include <linux/err.h>
- #include <linux/soc/ti/k3-sec-proxy.h>
- #include <linux/soc/ti/ti_sci_protocol.h>
- #include "ti_sci.h"
- #include "ti_sci_static_data.h"
- /* List of all TI SCI devices active in system */
- static LIST_HEAD(ti_sci_list);
- /**
- * struct ti_sci_xfer - Structure representing a message flow
- * @tx_message: Transmit message
- * @rx_len: Receive message length
- */
- struct ti_sci_xfer {
- struct k3_sec_proxy_msg tx_message;
- u8 rx_len;
- };
- /**
- * struct ti_sci_rm_type_map - Structure representing TISCI Resource
- * management representation of dev_ids.
- * @dev_id: TISCI device ID
- * @type: Corresponding id as identified by TISCI RM.
- *
- * Note: This is used only as a work around for using RM range apis
- * for AM654 SoC. For future SoCs dev_id will be used as type
- * for RM range APIs. In order to maintain ABI backward compatibility
- * type is not being changed for AM654 SoC.
- */
- struct ti_sci_rm_type_map {
- u32 dev_id;
- u16 type;
- };
- /**
- * struct ti_sci_desc - Description of SoC integration
- * @default_host_id: Host identifier representing the compute entity
- * @max_rx_timeout_ms: Timeout for communication with SoC (in Milliseconds)
- * @max_msgs: Maximum number of messages that can be pending
- * simultaneously in the system
- * @max_msg_size: Maximum size of data per message that can be handled.
- */
- struct ti_sci_desc {
- u8 default_host_id;
- int max_rx_timeout_ms;
- int max_msgs;
- int max_msg_size;
- };
- /**
- * struct ti_sci_info - Structure representing a TI SCI instance
- * @dev: Device pointer
- * @desc: SoC description for this instance
- * @handle: Instance of TI SCI handle to send to clients.
- * @chan_tx: Transmit mailbox channel
- * @chan_rx: Receive mailbox channel
- * @xfer: xfer info
- * @list: list head
- * @is_secure: Determines if the communication is through secure threads.
- * @host_id: Host identifier representing the compute entity
- * @seq: Seq id used for verification for tx and rx message.
- */
- struct ti_sci_info {
- struct udevice *dev;
- const struct ti_sci_desc *desc;
- struct ti_sci_handle handle;
- struct mbox_chan chan_tx;
- struct mbox_chan chan_rx;
- struct mbox_chan chan_notify;
- struct ti_sci_xfer xfer;
- struct list_head list;
- struct list_head dev_list;
- bool is_secure;
- u8 host_id;
- u8 seq;
- };
- struct ti_sci_exclusive_dev {
- u32 id;
- u32 count;
- struct list_head list;
- };
- #define handle_to_ti_sci_info(h) container_of(h, struct ti_sci_info, handle)
- /**
- * ti_sci_setup_one_xfer() - Setup one message type
- * @info: Pointer to SCI entity information
- * @msg_type: Message type
- * @msg_flags: Flag to set for the message
- * @buf: Buffer to be send to mailbox channel
- * @tx_message_size: transmit message size
- * @rx_message_size: receive message size. may be set to zero for send-only
- * transactions.
- *
- * Helper function which is used by various command functions that are
- * exposed to clients of this driver for allocating a message traffic event.
- *
- * Return: Corresponding ti_sci_xfer pointer if all went fine,
- * else appropriate error pointer.
- */
- static struct ti_sci_xfer *ti_sci_setup_one_xfer(struct ti_sci_info *info,
- u16 msg_type, u32 msg_flags,
- u32 *buf,
- size_t tx_message_size,
- size_t rx_message_size)
- {
- struct ti_sci_xfer *xfer = &info->xfer;
- struct ti_sci_msg_hdr *hdr;
- /* Ensure we have sane transfer sizes */
- if (rx_message_size > info->desc->max_msg_size ||
- tx_message_size > info->desc->max_msg_size ||
- (rx_message_size > 0 && rx_message_size < sizeof(*hdr)) ||
- tx_message_size < sizeof(*hdr))
- return ERR_PTR(-ERANGE);
- info->seq = ~info->seq;
- xfer->tx_message.buf = buf;
- xfer->tx_message.len = tx_message_size;
- xfer->rx_len = (u8)rx_message_size;
- hdr = (struct ti_sci_msg_hdr *)buf;
- hdr->seq = info->seq;
- hdr->type = msg_type;
- hdr->host = info->host_id;
- hdr->flags = msg_flags;
- return xfer;
- }
- /**
- * ti_sci_get_response() - Receive response from mailbox channel
- * @info: Pointer to SCI entity information
- * @xfer: Transfer to initiate and wait for response
- * @chan: Channel to receive the response
- *
- * Return: -ETIMEDOUT in case of no response, if transmit error,
- * return corresponding error, else if all goes well,
- * return 0.
- */
- static inline int ti_sci_get_response(struct ti_sci_info *info,
- struct ti_sci_xfer *xfer,
- struct mbox_chan *chan)
- {
- struct k3_sec_proxy_msg *msg = &xfer->tx_message;
- struct ti_sci_secure_msg_hdr *secure_hdr;
- struct ti_sci_msg_hdr *hdr;
- int ret;
- /* Receive the response */
- ret = mbox_recv(chan, msg, info->desc->max_rx_timeout_ms * 1000);
- if (ret) {
- dev_err(info->dev, "%s: Message receive failed. ret = %d\n",
- __func__, ret);
- return ret;
- }
- /* ToDo: Verify checksum */
- if (info->is_secure) {
- secure_hdr = (struct ti_sci_secure_msg_hdr *)msg->buf;
- msg->buf = (u32 *)((void *)msg->buf + sizeof(*secure_hdr));
- }
- /* msg is updated by mailbox driver */
- hdr = (struct ti_sci_msg_hdr *)msg->buf;
- /* Sanity check for message response */
- if (hdr->seq != info->seq) {
- dev_dbg(info->dev, "%s: Message for %d is not expected\n",
- __func__, hdr->seq);
- return ret;
- }
- if (msg->len > info->desc->max_msg_size) {
- dev_err(info->dev, "%s: Unable to handle %zu xfer (max %d)\n",
- __func__, msg->len, info->desc->max_msg_size);
- return -EINVAL;
- }
- if (msg->len < xfer->rx_len) {
- dev_err(info->dev, "%s: Recv xfer %zu < expected %d length\n",
- __func__, msg->len, xfer->rx_len);
- }
- return ret;
- }
- /**
- * ti_sci_do_xfer() - Do one transfer
- * @info: Pointer to SCI entity information
- * @xfer: Transfer to initiate and wait for response
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static inline int ti_sci_do_xfer(struct ti_sci_info *info,
- struct ti_sci_xfer *xfer)
- {
- struct k3_sec_proxy_msg *msg = &xfer->tx_message;
- u8 secure_buf[info->desc->max_msg_size];
- struct ti_sci_secure_msg_hdr secure_hdr;
- int ret;
- if (info->is_secure) {
- /* ToDo: get checksum of the entire message */
- secure_hdr.checksum = 0;
- secure_hdr.reserved = 0;
- memcpy(&secure_buf[sizeof(secure_hdr)], xfer->tx_message.buf,
- xfer->tx_message.len);
- xfer->tx_message.buf = (u32 *)secure_buf;
- xfer->tx_message.len += sizeof(secure_hdr);
- if (xfer->rx_len)
- xfer->rx_len += sizeof(secure_hdr);
- }
- /* Send the message */
- ret = mbox_send(&info->chan_tx, msg);
- if (ret) {
- dev_err(info->dev, "%s: Message sending failed. ret = %d\n",
- __func__, ret);
- return ret;
- }
- /* Get response if requested */
- if (xfer->rx_len)
- ret = ti_sci_get_response(info, xfer, &info->chan_rx);
- return ret;
- }
- /**
- * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
- * @handle: pointer to TI SCI handle
- *
- * Updates the SCI information in the internal data structure.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
- {
- struct ti_sci_msg_resp_version *rev_info;
- struct ti_sci_version_info *ver;
- struct ti_sci_msg_hdr hdr;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_VERSION,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&hdr, sizeof(struct ti_sci_msg_hdr),
- sizeof(*rev_info));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox communication fail %d\n", ret);
- return ret;
- }
- rev_info = (struct ti_sci_msg_resp_version *)xfer->tx_message.buf;
- ver = &handle->version;
- ver->abi_major = rev_info->abi_major;
- ver->abi_minor = rev_info->abi_minor;
- ver->firmware_revision = rev_info->firmware_revision;
- strncpy(ver->firmware_description, rev_info->firmware_description,
- sizeof(ver->firmware_description));
- return 0;
- }
- /**
- * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
- * @r: pointer to response buffer
- *
- * Return: true if the response was an ACK, else returns false.
- */
- static inline bool ti_sci_is_response_ack(void *r)
- {
- struct ti_sci_msg_hdr *hdr = r;
- return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false;
- }
- /**
- * cmd_set_board_config_using_msg() - Common command to send board configuration
- * message
- * @handle: pointer to TI SCI handle
- * @msg_type: One of the TISCI message types to set board configuration
- * @addr: Address where the board config structure is located
- * @size: Size of the board config structure
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int cmd_set_board_config_using_msg(const struct ti_sci_handle *handle,
- u16 msg_type, u64 addr, u32 size)
- {
- struct ti_sci_msg_board_config req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, msg_type,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.boardcfgp_high = (addr >> 32) & 0xffffffff;
- req.boardcfgp_low = addr & 0xffffffff;
- req.boardcfg_size = size;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_set_board_config() - Command to send board configuration message
- * @handle: pointer to TI SCI handle
- * @addr: Address where the board config structure is located
- * @size: Size of the board config structure
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_set_board_config(const struct ti_sci_handle *handle,
- u64 addr, u32 size)
- {
- return cmd_set_board_config_using_msg(handle,
- TI_SCI_MSG_BOARD_CONFIG,
- addr, size);
- }
- /**
- * ti_sci_cmd_set_board_config_rm() - Command to send board resource
- * management configuration
- * @handle: pointer to TI SCI handle
- * @addr: Address where the board RM config structure is located
- * @size: Size of the RM config structure
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static
- int ti_sci_cmd_set_board_config_rm(const struct ti_sci_handle *handle,
- u64 addr, u32 size)
- {
- return cmd_set_board_config_using_msg(handle,
- TI_SCI_MSG_BOARD_CONFIG_RM,
- addr, size);
- }
- /**
- * ti_sci_cmd_set_board_config_security() - Command to send board security
- * configuration message
- * @handle: pointer to TI SCI handle
- * @addr: Address where the board security config structure is located
- * @size: Size of the security config structure
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static
- int ti_sci_cmd_set_board_config_security(const struct ti_sci_handle *handle,
- u64 addr, u32 size)
- {
- return cmd_set_board_config_using_msg(handle,
- TI_SCI_MSG_BOARD_CONFIG_SECURITY,
- addr, size);
- }
- /**
- * ti_sci_cmd_set_board_config_pm() - Command to send board power and clock
- * configuration message
- * @handle: pointer to TI SCI handle
- * @addr: Address where the board PM config structure is located
- * @size: Size of the PM config structure
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_set_board_config_pm(const struct ti_sci_handle *handle,
- u64 addr, u32 size)
- {
- return cmd_set_board_config_using_msg(handle,
- TI_SCI_MSG_BOARD_CONFIG_PM,
- addr, size);
- }
- static struct ti_sci_exclusive_dev
- *ti_sci_get_exclusive_dev(struct list_head *dev_list, u32 id)
- {
- struct ti_sci_exclusive_dev *dev;
- list_for_each_entry(dev, dev_list, list)
- if (dev->id == id)
- return dev;
- return NULL;
- }
- static void ti_sci_add_exclusive_dev(struct ti_sci_info *info, u32 id)
- {
- struct ti_sci_exclusive_dev *dev;
- dev = ti_sci_get_exclusive_dev(&info->dev_list, id);
- if (dev) {
- dev->count++;
- return;
- }
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- dev->id = id;
- dev->count = 1;
- INIT_LIST_HEAD(&dev->list);
- list_add_tail(&dev->list, &info->dev_list);
- }
- static void ti_sci_delete_exclusive_dev(struct ti_sci_info *info, u32 id)
- {
- struct ti_sci_exclusive_dev *dev;
- dev = ti_sci_get_exclusive_dev(&info->dev_list, id);
- if (!dev)
- return;
- if (dev->count > 0)
- dev->count--;
- }
- /**
- * ti_sci_set_device_state() - Set device state helper
- * @handle: pointer to TI SCI handle
- * @id: Device identifier
- * @flags: flags to setup for the device
- * @state: State to move the device to
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
- u32 id, u32 flags, u8 state)
- {
- struct ti_sci_msg_req_set_device_state req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_DEVICE_STATE,
- flags | TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.id = id;
- req.state = state;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- if (state == MSG_DEVICE_SW_STATE_AUTO_OFF)
- ti_sci_delete_exclusive_dev(info, id);
- else if (flags & MSG_FLAG_DEVICE_EXCLUSIVE)
- ti_sci_add_exclusive_dev(info, id);
- return ret;
- }
- /**
- * ti_sci_set_device_state_no_wait() - Set device state helper without
- * requesting or waiting for a response.
- * @handle: pointer to TI SCI handle
- * @id: Device identifier
- * @flags: flags to setup for the device
- * @state: State to move the device to
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_set_device_state_no_wait(const struct ti_sci_handle *handle,
- u32 id, u32 flags, u8 state)
- {
- struct ti_sci_msg_req_set_device_state req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_DEVICE_STATE,
- flags | TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
- (u32 *)&req, sizeof(req), 0);
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.id = id;
- req.state = state;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret)
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- /**
- * ti_sci_get_device_state() - Get device state helper
- * @handle: Handle to the device
- * @id: Device Identifier
- * @clcnt: Pointer to Context Loss Count
- * @resets: pointer to resets
- * @p_state: pointer to p_state
- * @c_state: pointer to c_state
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
- u32 id, u32 *clcnt, u32 *resets,
- u8 *p_state, u8 *c_state)
- {
- struct ti_sci_msg_resp_get_device_state *resp;
- struct ti_sci_msg_req_get_device_state req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- if (!clcnt && !resets && !p_state && !c_state)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_DEVICE_STATE,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.id = id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_device_state *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- if (clcnt)
- *clcnt = resp->context_loss_count;
- if (resets)
- *resets = resp->resets;
- if (p_state)
- *p_state = resp->programmed_state;
- if (c_state)
- *c_state = resp->current_state;
- return ret;
- }
- /**
- * ti_sci_cmd_get_device() - command to request for device managed by TISCI
- * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
- * @id: Device Identifier
- *
- * Request for the device - NOTE: the client MUST maintain integrity of
- * usage count by balancing get_device with put_device. No refcounting is
- * managed by driver for that purpose.
- *
- * NOTE: The request is for exclusive access for the processor.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
- {
- return ti_sci_set_device_state(handle, id, 0,
- MSG_DEVICE_SW_STATE_ON);
- }
- static int ti_sci_cmd_get_device_exclusive(const struct ti_sci_handle *handle,
- u32 id)
- {
- return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
- MSG_DEVICE_SW_STATE_ON);
- }
- /**
- * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
- * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
- * @id: Device Identifier
- *
- * Request for the device - NOTE: the client MUST maintain integrity of
- * usage count by balancing get_device with put_device. No refcounting is
- * managed by driver for that purpose.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
- {
- return ti_sci_set_device_state(handle, id,
- 0,
- MSG_DEVICE_SW_STATE_RETENTION);
- }
- static int ti_sci_cmd_idle_device_exclusive(const struct ti_sci_handle *handle,
- u32 id)
- {
- return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
- MSG_DEVICE_SW_STATE_RETENTION);
- }
- /**
- * ti_sci_cmd_put_device() - command to release a device managed by TISCI
- * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
- * @id: Device Identifier
- *
- * Request for the device - NOTE: the client MUST maintain integrity of
- * usage count by balancing get_device with put_device. No refcounting is
- * managed by driver for that purpose.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id)
- {
- return ti_sci_set_device_state(handle, id, 0,
- MSG_DEVICE_SW_STATE_AUTO_OFF);
- }
- static
- int ti_sci_cmd_release_exclusive_devices(const struct ti_sci_handle *handle)
- {
- struct ti_sci_exclusive_dev *dev, *tmp;
- struct ti_sci_info *info;
- int i, cnt;
- info = handle_to_ti_sci_info(handle);
- list_for_each_entry_safe(dev, tmp, &info->dev_list, list) {
- cnt = dev->count;
- debug("%s: id = %d, cnt = %d\n", __func__, dev->id, cnt);
- for (i = 0; i < cnt; i++)
- ti_sci_cmd_put_device(handle, dev->id);
- }
- return 0;
- }
- /**
- * ti_sci_cmd_dev_is_valid() - Is the device valid
- * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
- * @id: Device Identifier
- *
- * Return: 0 if all went fine and the device ID is valid, else return
- * appropriate error.
- */
- static int ti_sci_cmd_dev_is_valid(const struct ti_sci_handle *handle, u32 id)
- {
- u8 unused;
- /* check the device state which will also tell us if the ID is valid */
- return ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &unused);
- }
- /**
- * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @count: Pointer to Context Loss counter to populate
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_dev_get_clcnt(const struct ti_sci_handle *handle, u32 id,
- u32 *count)
- {
- return ti_sci_get_device_state(handle, id, count, NULL, NULL, NULL);
- }
- /**
- * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @r_state: true if requested to be idle
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_dev_is_idle(const struct ti_sci_handle *handle, u32 id,
- bool *r_state)
- {
- int ret;
- u8 state;
- if (!r_state)
- return -EINVAL;
- ret = ti_sci_get_device_state(handle, id, NULL, NULL, &state, NULL);
- if (ret)
- return ret;
- *r_state = (state == MSG_DEVICE_SW_STATE_RETENTION);
- return 0;
- }
- /**
- * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @r_state: true if requested to be stopped
- * @curr_state: true if currently stopped.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id,
- bool *r_state, bool *curr_state)
- {
- int ret;
- u8 p_state, c_state;
- if (!r_state && !curr_state)
- return -EINVAL;
- ret =
- ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state);
- if (ret)
- return ret;
- if (r_state)
- *r_state = (p_state == MSG_DEVICE_SW_STATE_AUTO_OFF);
- if (curr_state)
- *curr_state = (c_state == MSG_DEVICE_HW_STATE_OFF);
- return 0;
- }
- /**
- * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @r_state: true if requested to be ON
- * @curr_state: true if currently ON and active
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_dev_is_on(const struct ti_sci_handle *handle, u32 id,
- bool *r_state, bool *curr_state)
- {
- int ret;
- u8 p_state, c_state;
- if (!r_state && !curr_state)
- return -EINVAL;
- ret =
- ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state);
- if (ret)
- return ret;
- if (r_state)
- *r_state = (p_state == MSG_DEVICE_SW_STATE_ON);
- if (curr_state)
- *curr_state = (c_state == MSG_DEVICE_HW_STATE_ON);
- return 0;
- }
- /**
- * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @curr_state: true if currently transitioning.
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id,
- bool *curr_state)
- {
- int ret;
- u8 state;
- if (!curr_state)
- return -EINVAL;
- ret = ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &state);
- if (ret)
- return ret;
- *curr_state = (state == MSG_DEVICE_HW_STATE_TRANS);
- return 0;
- }
- /**
- * ti_sci_cmd_set_device_resets() - command to set resets for device managed
- * by TISCI
- * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
- * @id: Device Identifier
- * @reset_state: Device specific reset bit field
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,
- u32 id, u32 reset_state)
- {
- struct ti_sci_msg_req_set_device_resets req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_DEVICE_RESETS,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.id = id;
- req.resets = reset_state;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_get_device_resets() - Get reset state for device managed
- * by TISCI
- * @handle: Pointer to TISCI handle
- * @id: Device Identifier
- * @reset_state: Pointer to reset state to populate
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_get_device_resets(const struct ti_sci_handle *handle,
- u32 id, u32 *reset_state)
- {
- return ti_sci_get_device_state(handle, id, NULL, reset_state, NULL,
- NULL);
- }
- /**
- * ti_sci_set_clock_state() - Set clock state helper
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @flags: Header flags as needed
- * @state: State to request for the clock.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id,
- u32 flags, u8 state)
- {
- struct ti_sci_msg_req_set_clock_state req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_CLOCK_STATE,
- flags | TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- req.request_state = state;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_get_clock_state() - Get clock state helper
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @programmed_state: State requested for clock to move to
- * @current_state: State that the clock is currently in
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id,
- u8 *programmed_state, u8 *current_state)
- {
- struct ti_sci_msg_resp_get_clock_state *resp;
- struct ti_sci_msg_req_get_clock_state req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- if (!programmed_state && !current_state)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_CLOCK_STATE,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- if (programmed_state)
- *programmed_state = resp->programmed_state;
- if (current_state)
- *current_state = resp->current_state;
- return ret;
- }
- /**
- * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @needs_ssc: 'true' if Spread Spectrum clock is desired, else 'false'
- * @can_change_freq: 'true' if frequency change is desired, else 'false'
- * @enable_input_term: 'true' if input termination is desired, else 'false'
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_get_clock(const struct ti_sci_handle *handle, u32 dev_id,
- u8 clk_id, bool needs_ssc, bool can_change_freq,
- bool enable_input_term)
- {
- u32 flags = 0;
- flags |= needs_ssc ? MSG_FLAG_CLOCK_ALLOW_SSC : 0;
- flags |= can_change_freq ? MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE : 0;
- flags |= enable_input_term ? MSG_FLAG_CLOCK_INPUT_TERM : 0;
- return ti_sci_set_clock_state(handle, dev_id, clk_id, flags,
- MSG_CLOCK_SW_STATE_REQ);
- }
- /**
- * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- *
- * NOTE: This clock must have been requested by get_clock previously.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_idle_clock(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id)
- {
- return ti_sci_set_clock_state(handle, dev_id, clk_id, 0,
- MSG_CLOCK_SW_STATE_UNREQ);
- }
- /**
- * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- *
- * NOTE: This clock must have been requested by get_clock previously.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_put_clock(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id)
- {
- return ti_sci_set_clock_state(handle, dev_id, clk_id, 0,
- MSG_CLOCK_SW_STATE_AUTO);
- }
- /**
- * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @req_state: state indicating if the clock is auto managed
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_is_auto(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, bool *req_state)
- {
- u8 state = 0;
- int ret;
- if (!req_state)
- return -EINVAL;
- ret = ti_sci_cmd_get_clock_state(handle, dev_id, clk_id, &state, NULL);
- if (ret)
- return ret;
- *req_state = (state == MSG_CLOCK_SW_STATE_AUTO);
- return 0;
- }
- /**
- * ti_sci_cmd_clk_is_on() - Is the clock ON
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @req_state: state indicating if the clock is managed by us and enabled
- * @curr_state: state indicating if the clock is ready for operation
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_is_on(const struct ti_sci_handle *handle, u32 dev_id,
- u8 clk_id, bool *req_state, bool *curr_state)
- {
- u8 c_state = 0, r_state = 0;
- int ret;
- if (!req_state && !curr_state)
- return -EINVAL;
- ret = ti_sci_cmd_get_clock_state(handle, dev_id, clk_id,
- &r_state, &c_state);
- if (ret)
- return ret;
- if (req_state)
- *req_state = (r_state == MSG_CLOCK_SW_STATE_REQ);
- if (curr_state)
- *curr_state = (c_state == MSG_CLOCK_HW_STATE_READY);
- return 0;
- }
- /**
- * ti_sci_cmd_clk_is_off() - Is the clock OFF
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @req_state: state indicating if the clock is managed by us and disabled
- * @curr_state: state indicating if the clock is NOT ready for operation
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_is_off(const struct ti_sci_handle *handle, u32 dev_id,
- u8 clk_id, bool *req_state, bool *curr_state)
- {
- u8 c_state = 0, r_state = 0;
- int ret;
- if (!req_state && !curr_state)
- return -EINVAL;
- ret = ti_sci_cmd_get_clock_state(handle, dev_id, clk_id,
- &r_state, &c_state);
- if (ret)
- return ret;
- if (req_state)
- *req_state = (r_state == MSG_CLOCK_SW_STATE_UNREQ);
- if (curr_state)
- *curr_state = (c_state == MSG_CLOCK_HW_STATE_NOT_READY);
- return 0;
- }
- /**
- * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @parent_id: Parent clock identifier to set
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, u8 parent_id)
- {
- struct ti_sci_msg_req_set_clock_parent req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_CLOCK_PARENT,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- req.parent_id = parent_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_clk_get_parent() - Get current parent clock source
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @parent_id: Current clock parent
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, u8 *parent_id)
- {
- struct ti_sci_msg_resp_get_clock_parent *resp;
- struct ti_sci_msg_req_get_clock_parent req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle || !parent_id)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_CLOCK_PARENT,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- else
- *parent_id = resp->parent_id;
- return ret;
- }
- /**
- * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @num_parents: Returns he number of parents to the current clock.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id,
- u8 *num_parents)
- {
- struct ti_sci_msg_resp_get_clock_num_parents *resp;
- struct ti_sci_msg_req_get_clock_num_parents req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle || !num_parents)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_NUM_CLOCK_PARENTS,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_clock_num_parents *)
- xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- else
- *num_parents = resp->num_parents;
- return ret;
- }
- /**
- * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @min_freq: The minimum allowable frequency in Hz. This is the minimum
- * allowable programmed frequency and does not account for clock
- * tolerances and jitter.
- * @target_freq: The target clock frequency in Hz. A frequency will be
- * processed as close to this target frequency as possible.
- * @max_freq: The maximum allowable frequency in Hz. This is the maximum
- * allowable programmed frequency and does not account for clock
- * tolerances and jitter.
- * @match_freq: Frequency match in Hz response.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, u64 min_freq,
- u64 target_freq, u64 max_freq,
- u64 *match_freq)
- {
- struct ti_sci_msg_resp_query_clock_freq *resp;
- struct ti_sci_msg_req_query_clock_freq req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle || !match_freq)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_QUERY_CLOCK_FREQ,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- req.min_freq_hz = min_freq;
- req.target_freq_hz = target_freq;
- req.max_freq_hz = max_freq;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- else
- *match_freq = resp->freq_hz;
- return ret;
- }
- /**
- * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @min_freq: The minimum allowable frequency in Hz. This is the minimum
- * allowable programmed frequency and does not account for clock
- * tolerances and jitter.
- * @target_freq: The target clock frequency in Hz. A frequency will be
- * processed as close to this target frequency as possible.
- * @max_freq: The maximum allowable frequency in Hz. This is the maximum
- * allowable programmed frequency and does not account for clock
- * tolerances and jitter.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, u64 min_freq,
- u64 target_freq, u64 max_freq)
- {
- struct ti_sci_msg_req_set_clock_freq req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SET_CLOCK_FREQ,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- req.min_freq_hz = min_freq;
- req.target_freq_hz = target_freq;
- req.max_freq_hz = max_freq;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_clk_get_freq() - Get current frequency
- * @handle: pointer to TI SCI handle
- * @dev_id: Device identifier this request is for
- * @clk_id: Clock identifier for the device for this request.
- * Each device has it's own set of clock inputs. This indexes
- * which clock input to modify.
- * @freq: Currently frequency in Hz
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,
- u32 dev_id, u8 clk_id, u64 *freq)
- {
- struct ti_sci_msg_resp_get_clock_freq *resp;
- struct ti_sci_msg_req_get_clock_freq req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle || !freq)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_CLOCK_FREQ,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.dev_id = dev_id;
- req.clk_id = clk_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- else
- *freq = resp->freq_hz;
- return ret;
- }
- /**
- * ti_sci_cmd_core_reboot() - Command to request system reset
- * @handle: pointer to TI SCI handle
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
- {
- struct ti_sci_msg_req_reboot req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_SYS_RESET,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.domain = 0;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return ret;
- }
- /**
- * ti_sci_get_resource_range - Helper to get a range of resources assigned
- * to a host. Resource is uniquely identified by
- * type and subtype.
- * @handle: Pointer to TISCI handle.
- * @dev_id: TISCI device ID.
- * @subtype: Resource assignment subtype that is being requested
- * from the given device.
- * @s_host: Host processor ID to which the resources are allocated
- * @range_start: Start index of the resource range
- * @range_num: Number of resources in the range
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
- u32 dev_id, u8 subtype, u8 s_host,
- u16 *range_start, u16 *range_num)
- {
- struct ti_sci_msg_resp_get_resource_range *resp;
- struct ti_sci_msg_req_get_resource_range req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_GET_RESOURCE_RANGE,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.secondary_host = s_host;
- req.type = dev_id & MSG_RM_RESOURCE_TYPE_MASK;
- req.subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- goto fail;
- }
- resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp)) {
- ret = -ENODEV;
- } else if (!resp->range_start && !resp->range_num) {
- ret = -ENODEV;
- } else {
- *range_start = resp->range_start;
- *range_num = resp->range_num;
- };
- fail:
- return ret;
- }
- static int __maybe_unused
- ti_sci_cmd_get_resource_range_static(const struct ti_sci_handle *handle,
- u32 dev_id, u8 subtype,
- u16 *range_start, u16 *range_num)
- {
- struct ti_sci_resource_static_data *data;
- int i = 0;
- while (1) {
- data = &rm_static_data[i];
- if (!data->dev_id)
- return -EINVAL;
- if (data->dev_id != dev_id || data->subtype != subtype) {
- i++;
- continue;
- }
- *range_start = data->range_start;
- *range_num = data->range_num;
- return 0;
- }
- return -EINVAL;
- }
- /**
- * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
- * that is same as ti sci interface host.
- * @handle: Pointer to TISCI handle.
- * @dev_id: TISCI device ID.
- * @subtype: Resource assignment subtype that is being requested
- * from the given device.
- * @range_start: Start index of the resource range
- * @range_num: Number of resources in the range
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static int ti_sci_cmd_get_resource_range(const struct ti_sci_handle *handle,
- u32 dev_id, u8 subtype,
- u16 *range_start, u16 *range_num)
- {
- return ti_sci_get_resource_range(handle, dev_id, subtype,
- TI_SCI_IRQ_SECONDARY_HOST_INVALID,
- range_start, range_num);
- }
- /**
- * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
- * assigned to a specified host.
- * @handle: Pointer to TISCI handle.
- * @dev_id: TISCI device ID.
- * @subtype: Resource assignment subtype that is being requested
- * from the given device.
- * @s_host: Host processor ID to which the resources are allocated
- * @range_start: Start index of the resource range
- * @range_num: Number of resources in the range
- *
- * Return: 0 if all went fine, else return appropriate error.
- */
- static
- int ti_sci_cmd_get_resource_range_from_shost(const struct ti_sci_handle *handle,
- u32 dev_id, u8 subtype, u8 s_host,
- u16 *range_start, u16 *range_num)
- {
- return ti_sci_get_resource_range(handle, dev_id, subtype, s_host,
- range_start, range_num);
- }
- /**
- * ti_sci_cmd_query_msmc() - Command to query currently available msmc memory
- * @handle: pointer to TI SCI handle
- * @msms_start: MSMC start as returned by tisci
- * @msmc_end: MSMC end as returned by tisci
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_query_msmc(const struct ti_sci_handle *handle,
- u64 *msmc_start, u64 *msmc_end)
- {
- struct ti_sci_msg_resp_query_msmc *resp;
- struct ti_sci_msg_hdr req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_QUERY_MSMC,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_query_msmc *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- *msmc_start = ((u64)resp->msmc_start_high << TISCI_ADDR_HIGH_SHIFT) |
- resp->msmc_start_low;
- *msmc_end = ((u64)resp->msmc_end_high << TISCI_ADDR_HIGH_SHIFT) |
- resp->msmc_end_low;
- return ret;
- }
- /**
- * ti_sci_cmd_proc_request() - Command to request a physical processor control
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,
- u8 proc_id)
- {
- struct ti_sci_msg_req_proc_request req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_PROC_REQUEST,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_proc_release() - Command to release a physical processor control
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,
- u8 proc_id)
- {
- struct ti_sci_msg_req_proc_release req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_PROC_RELEASE,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_proc_handover() - Command to handover a physical processor
- * control to a host in the processor's access
- * control list.
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- * @host_id: Host ID to get the control of the processor
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,
- u8 proc_id, u8 host_id)
- {
- struct ti_sci_msg_req_proc_handover req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_PROC_HANDOVER,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- req.host_id = host_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_set_proc_boot_cfg() - Command to set the processor boot
- * configuration flags
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- * @config_flags_set: Configuration flags to be set
- * @config_flags_clear: Configuration flags to be cleared.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_set_proc_boot_cfg(const struct ti_sci_handle *handle,
- u8 proc_id, u64 bootvector,
- u32 config_flags_set,
- u32 config_flags_clear)
- {
- struct ti_sci_msg_req_set_proc_boot_config req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_SET_PROC_BOOT_CONFIG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- req.bootvector_low = bootvector & TISCI_ADDR_LOW_MASK;
- req.bootvector_high = (bootvector & TISCI_ADDR_HIGH_MASK) >>
- TISCI_ADDR_HIGH_SHIFT;
- req.config_flags_set = config_flags_set;
- req.config_flags_clear = config_flags_clear;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_set_proc_boot_ctrl() - Command to set the processor boot
- * control flags
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- * @control_flags_set: Control flags to be set
- * @control_flags_clear: Control flags to be cleared
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_set_proc_boot_ctrl(const struct ti_sci_handle *handle,
- u8 proc_id, u32 control_flags_set,
- u32 control_flags_clear)
- {
- struct ti_sci_msg_req_set_proc_boot_ctrl req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_SET_PROC_BOOT_CTRL,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- req.control_flags_set = control_flags_set;
- req.control_flags_clear = control_flags_clear;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- ret = -ENODEV;
- return ret;
- }
- /**
- * ti_sci_cmd_proc_auth_boot_image() - Command to authenticate and load the
- * image and then set the processor configuration flags.
- * @handle: Pointer to TI SCI handle
- * @image_addr: Memory address at which payload image and certificate is
- * located in memory, this is updated if the image data is
- * moved during authentication.
- * @image_size: This is updated with the final size of the image after
- * authentication.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
- u64 *image_addr, u32 *image_size)
- {
- struct ti_sci_msg_req_proc_auth_boot_image req;
- struct ti_sci_msg_resp_proc_auth_boot_image *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_PROC_AUTH_BOOT_IMIAGE,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.cert_addr_low = *image_addr & TISCI_ADDR_LOW_MASK;
- req.cert_addr_high = (*image_addr & TISCI_ADDR_HIGH_MASK) >>
- TISCI_ADDR_HIGH_SHIFT;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_proc_auth_boot_image *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- *image_addr = (resp->image_addr_low & TISCI_ADDR_LOW_MASK) |
- (((u64)resp->image_addr_high <<
- TISCI_ADDR_HIGH_SHIFT) & TISCI_ADDR_HIGH_MASK);
- *image_size = resp->image_size;
- return ret;
- }
- /**
- * ti_sci_cmd_get_proc_boot_status() - Command to get the processor boot status
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_get_proc_boot_status(const struct ti_sci_handle *handle,
- u8 proc_id, u64 *bv, u32 *cfg_flags,
- u32 *ctrl_flags, u32 *sts_flags)
- {
- struct ti_sci_msg_resp_get_proc_boot_status *resp;
- struct ti_sci_msg_req_get_proc_boot_status req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_GET_PROC_BOOT_STATUS,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_resp_get_proc_boot_status *)
- xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- *bv = (resp->bootvector_low & TISCI_ADDR_LOW_MASK) |
- (((u64)resp->bootvector_high <<
- TISCI_ADDR_HIGH_SHIFT) & TISCI_ADDR_HIGH_MASK);
- *cfg_flags = resp->config_flags;
- *ctrl_flags = resp->control_flags;
- *sts_flags = resp->status_flags;
- return ret;
- }
- /**
- * ti_sci_proc_wait_boot_status_no_wait() - Helper function to wait for a
- * processor boot status without requesting or
- * waiting for a response.
- * @proc_id: Processor ID this request is for
- * @num_wait_iterations: Total number of iterations we will check before
- * we will timeout and give up
- * @num_match_iterations: How many iterations should we have continued
- * status to account for status bits glitching.
- * This is to make sure that match occurs for
- * consecutive checks. This implies that the
- * worst case should consider that the stable
- * time should at the worst be num_wait_iterations
- * num_match_iterations to prevent timeout.
- * @delay_per_iteration_us: Specifies how long to wait (in micro seconds)
- * between each status checks. This is the minimum
- * duration, and overhead of register reads and
- * checks are on top of this and can vary based on
- * varied conditions.
- * @delay_before_iterations_us: Specifies how long to wait (in micro seconds)
- * before the very first check in the first
- * iteration of status check loop. This is the
- * minimum duration, and overhead of register
- * reads and checks are.
- * @status_flags_1_set_all_wait:If non-zero, Specifies that all bits of the
- * status matching this field requested MUST be 1.
- * @status_flags_1_set_any_wait:If non-zero, Specifies that at least one of the
- * bits matching this field requested MUST be 1.
- * @status_flags_1_clr_all_wait:If non-zero, Specifies that all bits of the
- * status matching this field requested MUST be 0.
- * @status_flags_1_clr_any_wait:If non-zero, Specifies that at least one of the
- * bits matching this field requested MUST be 0.
- *
- * Return: 0 if all goes well, else appropriate error message
- */
- static int
- ti_sci_proc_wait_boot_status_no_wait(const struct ti_sci_handle *handle,
- u8 proc_id,
- u8 num_wait_iterations,
- u8 num_match_iterations,
- u8 delay_per_iteration_us,
- u8 delay_before_iterations_us,
- u32 status_flags_1_set_all_wait,
- u32 status_flags_1_set_any_wait,
- u32 status_flags_1_clr_all_wait,
- u32 status_flags_1_clr_any_wait)
- {
- struct ti_sci_msg_req_wait_proc_boot_status req;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_WAIT_PROC_BOOT_STATUS,
- TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
- (u32 *)&req, sizeof(req), 0);
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.processor_id = proc_id;
- req.num_wait_iterations = num_wait_iterations;
- req.num_match_iterations = num_match_iterations;
- req.delay_per_iteration_us = delay_per_iteration_us;
- req.delay_before_iterations_us = delay_before_iterations_us;
- req.status_flags_1_set_all_wait = status_flags_1_set_all_wait;
- req.status_flags_1_set_any_wait = status_flags_1_set_any_wait;
- req.status_flags_1_clr_all_wait = status_flags_1_clr_all_wait;
- req.status_flags_1_clr_any_wait = status_flags_1_clr_any_wait;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret)
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- /**
- * ti_sci_cmd_proc_shutdown_no_wait() - Command to shutdown a core without
- * requesting or waiting for a response. Note that this API call
- * should be followed by placing the respective processor into
- * either WFE or WFI mode.
- * @handle: Pointer to TI SCI handle
- * @proc_id: Processor ID this request is for
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_proc_shutdown_no_wait(const struct ti_sci_handle *handle,
- u8 proc_id)
- {
- int ret;
- struct ti_sci_info *info;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- /*
- * Send the core boot status wait message waiting for either WFE or
- * WFI without requesting or waiting for a TISCI response with the
- * maximum wait time to give us the best chance to get to the WFE/WFI
- * command that should follow the invocation of this API before the
- * DMSC-internal processing of this command times out. Note that
- * waiting for the R5 WFE/WFI flags will also work on an ARMV8 type
- * core as the related flag bit positions are the same.
- */
- ret = ti_sci_proc_wait_boot_status_no_wait(handle, proc_id,
- U8_MAX, 100, U8_MAX, U8_MAX,
- 0, PROC_BOOT_STATUS_FLAG_R5_WFE | PROC_BOOT_STATUS_FLAG_R5_WFI,
- 0, 0);
- if (ret) {
- dev_err(info->dev, "Sending core %u wait message fail %d\n",
- proc_id, ret);
- return ret;
- }
- /*
- * Release a processor managed by TISCI without requesting or waiting
- * for a response.
- */
- ret = ti_sci_set_device_state_no_wait(handle, proc_id, 0,
- MSG_DEVICE_SW_STATE_AUTO_OFF);
- if (ret)
- dev_err(info->dev, "Sending core %u shutdown message fail %d\n",
- proc_id, ret);
- return ret;
- }
- /**
- * ti_sci_cmd_ring_config() - configure RA ring
- * @handle: pointer to TI SCI handle
- * @valid_params: Bitfield defining validity of ring configuration parameters.
- * @nav_id: Device ID of Navigator Subsystem from which the ring is allocated
- * @index: Ring index.
- * @addr_lo: The ring base address lo 32 bits
- * @addr_hi: The ring base address hi 32 bits
- * @count: Number of ring elements.
- * @mode: The mode of the ring
- * @size: The ring element size.
- * @order_id: Specifies the ring's bus order ID.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- *
- * See @ti_sci_msg_rm_ring_cfg_req for more info.
- */
- static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
- u32 valid_params, u16 nav_id, u16 index,
- u32 addr_lo, u32 addr_hi, u32 count,
- u8 mode, u8 size, u8 order_id)
- {
- struct ti_sci_msg_rm_ring_cfg_resp *resp;
- struct ti_sci_msg_rm_ring_cfg_req req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_RM_RING_CFG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "RM_RA:Message config failed(%d)\n", ret);
- return ret;
- }
- req.valid_params = valid_params;
- req.nav_id = nav_id;
- req.index = index;
- req.addr_lo = addr_lo;
- req.addr_hi = addr_hi;
- req.count = count;
- req.mode = mode;
- req.size = size;
- req.order_id = order_id;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "RM_RA:Mbox config send fail %d\n", ret);
- goto fail;
- }
- resp = (struct ti_sci_msg_rm_ring_cfg_resp *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
- fail:
- dev_dbg(info->dev, "RM_RA:config ring %u ret:%d\n", index, ret);
- return ret;
- }
- static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,
- u32 nav_id, u32 src_thread, u32 dst_thread)
- {
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_msg_psil_pair req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_RM_PSIL_PAIR,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "RM_PSIL:Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.nav_id = nav_id;
- req.src_thread = src_thread;
- req.dst_thread = dst_thread;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "RM_PSIL:Mbox send fail %d\n", ret);
- goto fail;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
- fail:
- dev_dbg(info->dev, "RM_PSIL: nav: %u link pair %u->%u ret:%u\n",
- nav_id, src_thread, dst_thread, ret);
- return ret;
- }
- static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,
- u32 nav_id, u32 src_thread, u32 dst_thread)
- {
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_msg_psil_unpair req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_RM_PSIL_UNPAIR,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "RM_PSIL:Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.nav_id = nav_id;
- req.src_thread = src_thread;
- req.dst_thread = dst_thread;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "RM_PSIL:Mbox send fail %d\n", ret);
- goto fail;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
- fail:
- dev_dbg(info->dev, "RM_PSIL: link unpair %u->%u ret:%u\n",
- src_thread, dst_thread, ret);
- return ret;
- }
- static int ti_sci_cmd_rm_udmap_tx_ch_cfg(
- const struct ti_sci_handle *handle,
- const struct ti_sci_msg_rm_udmap_tx_ch_cfg *params)
- {
- struct ti_sci_msg_rm_udmap_tx_ch_cfg_resp *resp;
- struct ti_sci_msg_rm_udmap_tx_ch_cfg_req req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_RM_UDMAP_TX_CH_CFG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message TX_CH_CFG alloc failed(%d)\n", ret);
- return ret;
- }
- req.valid_params = params->valid_params;
- req.nav_id = params->nav_id;
- req.index = params->index;
- req.tx_pause_on_err = params->tx_pause_on_err;
- req.tx_filt_einfo = params->tx_filt_einfo;
- req.tx_filt_pswords = params->tx_filt_pswords;
- req.tx_atype = params->tx_atype;
- req.tx_chan_type = params->tx_chan_type;
- req.tx_supr_tdpkt = params->tx_supr_tdpkt;
- req.tx_fetch_size = params->tx_fetch_size;
- req.tx_credit_count = params->tx_credit_count;
- req.txcq_qnum = params->txcq_qnum;
- req.tx_priority = params->tx_priority;
- req.tx_qos = params->tx_qos;
- req.tx_orderid = params->tx_orderid;
- req.fdepth = params->fdepth;
- req.tx_sched_priority = params->tx_sched_priority;
- req.tx_burst_size = params->tx_burst_size;
- req.tx_tdtype = params->tx_tdtype;
- req.extended_ch_type = params->extended_ch_type;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send TX_CH_CFG fail %d\n", ret);
- goto fail;
- }
- resp =
- (struct ti_sci_msg_rm_udmap_tx_ch_cfg_resp *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
- fail:
- dev_dbg(info->dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret);
- return ret;
- }
- static int ti_sci_cmd_rm_udmap_rx_ch_cfg(
- const struct ti_sci_handle *handle,
- const struct ti_sci_msg_rm_udmap_rx_ch_cfg *params)
- {
- struct ti_sci_msg_rm_udmap_rx_ch_cfg_resp *resp;
- struct ti_sci_msg_rm_udmap_rx_ch_cfg_req req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_RM_UDMAP_RX_CH_CFG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message RX_CH_CFG alloc failed(%d)\n", ret);
- return ret;
- }
- req.valid_params = params->valid_params;
- req.nav_id = params->nav_id;
- req.index = params->index;
- req.rx_fetch_size = params->rx_fetch_size;
- req.rxcq_qnum = params->rxcq_qnum;
- req.rx_priority = params->rx_priority;
- req.rx_qos = params->rx_qos;
- req.rx_orderid = params->rx_orderid;
- req.rx_sched_priority = params->rx_sched_priority;
- req.flowid_start = params->flowid_start;
- req.flowid_cnt = params->flowid_cnt;
- req.rx_pause_on_err = params->rx_pause_on_err;
- req.rx_atype = params->rx_atype;
- req.rx_chan_type = params->rx_chan_type;
- req.rx_ignore_short = params->rx_ignore_short;
- req.rx_ignore_long = params->rx_ignore_long;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send RX_CH_CFG fail %d\n", ret);
- goto fail;
- }
- resp =
- (struct ti_sci_msg_rm_udmap_rx_ch_cfg_resp *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
- fail:
- dev_dbg(info->dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret);
- return ret;
- }
- static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
- const struct ti_sci_handle *handle,
- const struct ti_sci_msg_rm_udmap_flow_cfg *params)
- {
- struct ti_sci_msg_rm_udmap_flow_cfg_resp *resp;
- struct ti_sci_msg_rm_udmap_flow_cfg_req req;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_RM_UDMAP_FLOW_CFG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "RX_FL_CFG: Message alloc failed(%d)\n",
- ret);
- return ret;
- }
- req.valid_params = params->valid_params;
- req.nav_id = params->nav_id;
- req.flow_index = params->flow_index;
- req.rx_einfo_present = params->rx_einfo_present;
- req.rx_psinfo_present = params->rx_psinfo_present;
- req.rx_error_handling = params->rx_error_handling;
- req.rx_desc_type = params->rx_desc_type;
- req.rx_sop_offset = params->rx_sop_offset;
- req.rx_dest_qnum = params->rx_dest_qnum;
- req.rx_src_tag_hi = params->rx_src_tag_hi;
- req.rx_src_tag_lo = params->rx_src_tag_lo;
- req.rx_dest_tag_hi = params->rx_dest_tag_hi;
- req.rx_dest_tag_lo = params->rx_dest_tag_lo;
- req.rx_src_tag_hi_sel = params->rx_src_tag_hi_sel;
- req.rx_src_tag_lo_sel = params->rx_src_tag_lo_sel;
- req.rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel;
- req.rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel;
- req.rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum;
- req.rx_fdq1_qnum = params->rx_fdq1_qnum;
- req.rx_fdq2_qnum = params->rx_fdq2_qnum;
- req.rx_fdq3_qnum = params->rx_fdq3_qnum;
- req.rx_ps_location = params->rx_ps_location;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "RX_FL_CFG: Mbox send fail %d\n", ret);
- goto fail;
- }
- resp =
- (struct ti_sci_msg_rm_udmap_flow_cfg_resp *)xfer->tx_message.buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
- fail:
- dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret);
- return ret;
- }
- /**
- * ti_sci_cmd_set_fwl_region() - Request for configuring a firewall region
- * @handle: pointer to TI SCI handle
- * @region: region configuration parameters
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_set_fwl_region(const struct ti_sci_handle *handle,
- const struct ti_sci_msg_fwl_region *region)
- {
- struct ti_sci_msg_fwl_set_firewall_region_req req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_SET,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.fwl_id = region->fwl_id;
- req.region = region->region;
- req.n_permission_regs = region->n_permission_regs;
- req.control = region->control;
- req.permissions[0] = region->permissions[0];
- req.permissions[1] = region->permissions[1];
- req.permissions[2] = region->permissions[2];
- req.start_address = region->start_address;
- req.end_address = region->end_address;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- return 0;
- }
- /**
- * ti_sci_cmd_get_fwl_region() - Request for getting a firewall region
- * @handle: pointer to TI SCI handle
- * @region: region configuration parameters
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_get_fwl_region(const struct ti_sci_handle *handle,
- struct ti_sci_msg_fwl_region *region)
- {
- struct ti_sci_msg_fwl_get_firewall_region_req req;
- struct ti_sci_msg_fwl_get_firewall_region_resp *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_GET,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.fwl_id = region->fwl_id;
- req.region = region->region;
- req.n_permission_regs = region->n_permission_regs;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_fwl_get_firewall_region_resp *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- region->fwl_id = resp->fwl_id;
- region->region = resp->region;
- region->n_permission_regs = resp->n_permission_regs;
- region->control = resp->control;
- region->permissions[0] = resp->permissions[0];
- region->permissions[1] = resp->permissions[1];
- region->permissions[2] = resp->permissions[2];
- region->start_address = resp->start_address;
- region->end_address = resp->end_address;
- return 0;
- }
- /**
- * ti_sci_cmd_change_fwl_owner() - Request for changing a firewall owner
- * @handle: pointer to TI SCI handle
- * @region: region configuration parameters
- *
- * Return: 0 if all went well, else returns appropriate error value.
- */
- static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle,
- struct ti_sci_msg_fwl_owner *owner)
- {
- struct ti_sci_msg_fwl_change_owner_info_req req;
- struct ti_sci_msg_fwl_change_owner_info_resp *resp;
- struct ti_sci_info *info;
- struct ti_sci_xfer *xfer;
- int ret = 0;
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- if (!handle)
- return -EINVAL;
- info = handle_to_ti_sci_info(handle);
- xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_CHANGE_OWNER,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- (u32 *)&req, sizeof(req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(info->dev, "Message alloc failed(%d)\n", ret);
- return ret;
- }
- req.fwl_id = owner->fwl_id;
- req.region = owner->region;
- req.owner_index = owner->owner_index;
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(info->dev, "Mbox send fail %d\n", ret);
- return ret;
- }
- resp = (struct ti_sci_msg_fwl_change_owner_info_resp *)xfer->tx_message.buf;
- if (!ti_sci_is_response_ack(resp))
- return -ENODEV;
- owner->fwl_id = resp->fwl_id;
- owner->region = resp->region;
- owner->owner_index = resp->owner_index;
- owner->owner_privid = resp->owner_privid;
- owner->owner_permission_bits = resp->owner_permission_bits;
- return ret;
- }
- /*
- * ti_sci_setup_ops() - Setup the operations structures
- * @info: pointer to TISCI pointer
- */
- static void ti_sci_setup_ops(struct ti_sci_info *info)
- {
- struct ti_sci_ops *ops = &info->handle.ops;
- struct ti_sci_board_ops *bops = &ops->board_ops;
- struct ti_sci_dev_ops *dops = &ops->dev_ops;
- struct ti_sci_clk_ops *cops = &ops->clk_ops;
- struct ti_sci_core_ops *core_ops = &ops->core_ops;
- struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops;
- struct ti_sci_proc_ops *pops = &ops->proc_ops;
- struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops;
- struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops;
- struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops;
- struct ti_sci_fwl_ops *fwl_ops = &ops->fwl_ops;
- bops->board_config = ti_sci_cmd_set_board_config;
- bops->board_config_rm = ti_sci_cmd_set_board_config_rm;
- bops->board_config_security = ti_sci_cmd_set_board_config_security;
- bops->board_config_pm = ti_sci_cmd_set_board_config_pm;
- dops->get_device = ti_sci_cmd_get_device;
- dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive;
- dops->idle_device = ti_sci_cmd_idle_device;
- dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive;
- dops->put_device = ti_sci_cmd_put_device;
- dops->is_valid = ti_sci_cmd_dev_is_valid;
- dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt;
- dops->is_idle = ti_sci_cmd_dev_is_idle;
- dops->is_stop = ti_sci_cmd_dev_is_stop;
- dops->is_on = ti_sci_cmd_dev_is_on;
- dops->is_transitioning = ti_sci_cmd_dev_is_trans;
- dops->set_device_resets = ti_sci_cmd_set_device_resets;
- dops->get_device_resets = ti_sci_cmd_get_device_resets;
- dops->release_exclusive_devices = ti_sci_cmd_release_exclusive_devices;
- cops->get_clock = ti_sci_cmd_get_clock;
- cops->idle_clock = ti_sci_cmd_idle_clock;
- cops->put_clock = ti_sci_cmd_put_clock;
- cops->is_auto = ti_sci_cmd_clk_is_auto;
- cops->is_on = ti_sci_cmd_clk_is_on;
- cops->is_off = ti_sci_cmd_clk_is_off;
- cops->set_parent = ti_sci_cmd_clk_set_parent;
- cops->get_parent = ti_sci_cmd_clk_get_parent;
- cops->get_num_parents = ti_sci_cmd_clk_get_num_parents;
- cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq;
- cops->set_freq = ti_sci_cmd_clk_set_freq;
- cops->get_freq = ti_sci_cmd_clk_get_freq;
- core_ops->reboot_device = ti_sci_cmd_core_reboot;
- core_ops->query_msmc = ti_sci_cmd_query_msmc;
- rm_core_ops->get_range = ti_sci_cmd_get_resource_range;
- rm_core_ops->get_range_from_shost =
- ti_sci_cmd_get_resource_range_from_shost;
- pops->proc_request = ti_sci_cmd_proc_request;
- pops->proc_release = ti_sci_cmd_proc_release;
- pops->proc_handover = ti_sci_cmd_proc_handover;
- pops->set_proc_boot_cfg = ti_sci_cmd_set_proc_boot_cfg;
- pops->set_proc_boot_ctrl = ti_sci_cmd_set_proc_boot_ctrl;
- pops->proc_auth_boot_image = ti_sci_cmd_proc_auth_boot_image;
- pops->get_proc_boot_status = ti_sci_cmd_get_proc_boot_status;
- pops->proc_shutdown_no_wait = ti_sci_cmd_proc_shutdown_no_wait;
- rops->config = ti_sci_cmd_ring_config;
- psilops->pair = ti_sci_cmd_rm_psil_pair;
- psilops->unpair = ti_sci_cmd_rm_psil_unpair;
- udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg;
- udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg;
- udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg;
- fwl_ops->set_fwl_region = ti_sci_cmd_set_fwl_region;
- fwl_ops->get_fwl_region = ti_sci_cmd_get_fwl_region;
- fwl_ops->change_fwl_owner = ti_sci_cmd_change_fwl_owner;
- }
- /**
- * ti_sci_get_handle_from_sysfw() - Get the TI SCI handle of the SYSFW
- * @dev: Pointer to the SYSFW device
- *
- * Return: pointer to handle if successful, else EINVAL if invalid conditions
- * are encountered.
- */
- const
- struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct udevice *sci_dev)
- {
- if (!sci_dev)
- return ERR_PTR(-EINVAL);
- struct ti_sci_info *info = dev_get_priv(sci_dev);
- if (!info)
- return ERR_PTR(-EINVAL);
- struct ti_sci_handle *handle = &info->handle;
- if (!handle)
- return ERR_PTR(-EINVAL);
- return handle;
- }
- /**
- * ti_sci_get_handle() - Get the TI SCI handle for a device
- * @dev: Pointer to device for which we want SCI handle
- *
- * Return: pointer to handle if successful, else EINVAL if invalid conditions
- * are encountered.
- */
- const struct ti_sci_handle *ti_sci_get_handle(struct udevice *dev)
- {
- if (!dev)
- return ERR_PTR(-EINVAL);
- struct udevice *sci_dev = dev_get_parent(dev);
- return ti_sci_get_handle_from_sysfw(sci_dev);
- }
- /**
- * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
- * @dev: device node
- * @propname: property name containing phandle on TISCI node
- *
- * Return: pointer to handle if successful, else appropriate error value.
- */
- const struct ti_sci_handle *ti_sci_get_by_phandle(struct udevice *dev,
- const char *property)
- {
- struct ti_sci_info *entry, *info = NULL;
- u32 phandle, err;
- ofnode node;
- err = ofnode_read_u32(dev_ofnode(dev), property, &phandle);
- if (err)
- return ERR_PTR(err);
- node = ofnode_get_by_phandle(phandle);
- if (!ofnode_valid(node))
- return ERR_PTR(-EINVAL);
- list_for_each_entry(entry, &ti_sci_list, list)
- if (ofnode_equal(dev_ofnode(entry->dev), node)) {
- info = entry;
- break;
- }
- if (!info)
- return ERR_PTR(-ENODEV);
- return &info->handle;
- }
- /**
- * ti_sci_of_to_info() - generate private data from device tree
- * @dev: corresponding system controller interface device
- * @info: pointer to driver specific private data
- *
- * Return: 0 if all goes good, else appropriate error message.
- */
- static int ti_sci_of_to_info(struct udevice *dev, struct ti_sci_info *info)
- {
- int ret;
- ret = mbox_get_by_name(dev, "tx", &info->chan_tx);
- if (ret) {
- dev_err(dev, "%s: Acquiring Tx channel failed. ret = %d\n",
- __func__, ret);
- return ret;
- }
- ret = mbox_get_by_name(dev, "rx", &info->chan_rx);
- if (ret) {
- dev_err(dev, "%s: Acquiring Rx channel failed. ret = %d\n",
- __func__, ret);
- return ret;
- }
- /* Notify channel is optional. Enable only if populated */
- ret = mbox_get_by_name(dev, "notify", &info->chan_notify);
- if (ret) {
- dev_dbg(dev, "%s: Acquiring notify channel failed. ret = %d\n",
- __func__, ret);
- }
- info->host_id = dev_read_u32_default(dev, "ti,host-id",
- info->desc->default_host_id);
- info->is_secure = dev_read_bool(dev, "ti,secure-host");
- return 0;
- }
- /**
- * ti_sci_probe() - Basic probe
- * @dev: corresponding system controller interface device
- *
- * Return: 0 if all goes good, else appropriate error message.
- */
- static int ti_sci_probe(struct udevice *dev)
- {
- struct ti_sci_info *info;
- int ret;
- debug("%s(dev=%p)\n", __func__, dev);
- info = dev_get_priv(dev);
- info->desc = (void *)dev_get_driver_data(dev);
- ret = ti_sci_of_to_info(dev, info);
- if (ret) {
- dev_err(dev, "%s: Probe failed with error %d\n", __func__, ret);
- return ret;
- }
- info->dev = dev;
- info->seq = 0xA;
- list_add_tail(&info->list, &ti_sci_list);
- ti_sci_setup_ops(info);
- ret = ti_sci_cmd_get_revision(&info->handle);
- INIT_LIST_HEAD(&info->dev_list);
- return ret;
- }
- /**
- * ti_sci_dm_probe() - Basic probe for DM to TIFS SCI
- * @dev: corresponding system controller interface device
- *
- * Return: 0 if all goes good, else appropriate error message.
- */
- static __maybe_unused int ti_sci_dm_probe(struct udevice *dev)
- {
- struct ti_sci_rm_core_ops *rm_core_ops;
- struct ti_sci_rm_udmap_ops *udmap_ops;
- struct ti_sci_rm_ringacc_ops *rops;
- struct ti_sci_rm_psil_ops *psilops;
- struct ti_sci_ops *ops;
- struct ti_sci_info *info;
- int ret;
- debug("%s(dev=%p)\n", __func__, dev);
- info = dev_get_priv(dev);
- info->desc = (void *)dev_get_driver_data(dev);
- ret = ti_sci_of_to_info(dev, info);
- if (ret) {
- dev_err(dev, "%s: Probe failed with error %d\n", __func__, ret);
- return ret;
- }
- info->dev = dev;
- info->seq = 0xA;
- list_add_tail(&info->list, &ti_sci_list);
- ops = &info->handle.ops;
- rm_core_ops = &ops->rm_core_ops;
- rm_core_ops->get_range = ti_sci_cmd_get_resource_range_static;
- rops = &ops->rm_ring_ops;
- rops->config = ti_sci_cmd_ring_config;
- psilops = &ops->rm_psil_ops;
- psilops->pair = ti_sci_cmd_rm_psil_pair;
- psilops->unpair = ti_sci_cmd_rm_psil_unpair;
- udmap_ops = &ops->rm_udmap_ops;
- udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg;
- udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg;
- udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg;
- return ret;
- }
- /*
- * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
- * @res: Pointer to the TISCI resource
- *
- * Return: resource num if all went ok else TI_SCI_RESOURCE_NULL.
- */
- u16 ti_sci_get_free_resource(struct ti_sci_resource *res)
- {
- u16 set, free_bit;
- for (set = 0; set < res->sets; set++) {
- free_bit = find_first_zero_bit(res->desc[set].res_map,
- res->desc[set].num);
- if (free_bit != res->desc[set].num) {
- set_bit(free_bit, res->desc[set].res_map);
- return res->desc[set].start + free_bit;
- }
- }
- return TI_SCI_RESOURCE_NULL;
- }
- /**
- * ti_sci_release_resource() - Release a resource from TISCI resource.
- * @res: Pointer to the TISCI resource
- */
- void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)
- {
- u16 set;
- for (set = 0; set < res->sets; set++) {
- if (res->desc[set].start <= id &&
- (res->desc[set].num + res->desc[set].start) > id)
- clear_bit(id - res->desc[set].start,
- res->desc[set].res_map);
- }
- }
- /**
- * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
- * @handle: TISCI handle
- * @dev: Device pointer to which the resource is assigned
- * @of_prop: property name by which the resource are represented
- *
- * Note: This function expects of_prop to be in the form of tuples
- * <type, subtype>. Allocates and initializes ti_sci_resource structure
- * for each of_prop. Client driver can directly call
- * ti_sci_(get_free, release)_resource apis for handling the resource.
- *
- * Return: Pointer to ti_sci_resource if all went well else appropriate
- * error pointer.
- */
- struct ti_sci_resource *
- devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
- struct udevice *dev, u32 dev_id, char *of_prop)
- {
- u32 resource_subtype;
- struct ti_sci_resource *res;
- bool valid_set = false;
- int sets, i, ret;
- u32 *temp;
- res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL);
- if (!res)
- return ERR_PTR(-ENOMEM);
- sets = dev_read_size(dev, of_prop);
- if (sets < 0) {
- dev_err(dev, "%s resource type ids not available\n", of_prop);
- return ERR_PTR(sets);
- }
- temp = malloc(sets);
- sets /= sizeof(u32);
- res->sets = sets;
- res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc),
- GFP_KERNEL);
- if (!res->desc)
- return ERR_PTR(-ENOMEM);
- ret = dev_read_u32_array(dev, of_prop, temp, res->sets);
- if (ret)
- return ERR_PTR(-EINVAL);
- for (i = 0; i < res->sets; i++) {
- resource_subtype = temp[i];
- ret = handle->ops.rm_core_ops.get_range(handle, dev_id,
- resource_subtype,
- &res->desc[i].start,
- &res->desc[i].num);
- if (ret) {
- dev_dbg(dev, "type %d subtype %d not allocated for host %d\n",
- dev_id, resource_subtype,
- handle_to_ti_sci_info(handle)->host_id);
- res->desc[i].start = 0;
- res->desc[i].num = 0;
- continue;
- }
- valid_set = true;
- dev_dbg(dev, "res type = %d, subtype = %d, start = %d, num = %d\n",
- dev_id, resource_subtype, res->desc[i].start,
- res->desc[i].num);
- res->desc[i].res_map =
- devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
- sizeof(*res->desc[i].res_map), GFP_KERNEL);
- if (!res->desc[i].res_map)
- return ERR_PTR(-ENOMEM);
- }
- if (valid_set)
- return res;
- return ERR_PTR(-EINVAL);
- }
- /* Description for K2G */
- static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
- .default_host_id = 2,
- /* Conservative duration */
- .max_rx_timeout_ms = 10000,
- /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */
- .max_msgs = 20,
- .max_msg_size = 64,
- };
- /* Description for AM654 */
- static const struct ti_sci_desc ti_sci_pmmc_am654_desc = {
- .default_host_id = 12,
- /* Conservative duration */
- .max_rx_timeout_ms = 10000,
- /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */
- .max_msgs = 20,
- .max_msg_size = 60,
- };
- /* Description for J721e DM to DMSC communication */
- static const struct ti_sci_desc ti_sci_dm_j721e_desc = {
- .default_host_id = 3,
- .max_rx_timeout_ms = 10000,
- .max_msgs = 20,
- .max_msg_size = 60,
- };
- static const struct udevice_id ti_sci_ids[] = {
- {
- .compatible = "ti,k2g-sci",
- .data = (ulong)&ti_sci_pmmc_k2g_desc
- },
- {
- .compatible = "ti,am654-sci",
- .data = (ulong)&ti_sci_pmmc_am654_desc
- },
- { /* Sentinel */ },
- };
- static __maybe_unused const struct udevice_id ti_sci_dm_ids[] = {
- {
- .compatible = "ti,j721e-dm-sci",
- .data = (ulong)&ti_sci_dm_j721e_desc
- },
- { /* Sentinel */ },
- };
- U_BOOT_DRIVER(ti_sci) = {
- .name = "ti_sci",
- .id = UCLASS_FIRMWARE,
- .of_match = ti_sci_ids,
- .probe = ti_sci_probe,
- .priv_auto = sizeof(struct ti_sci_info),
- };
- #if IS_ENABLED(CONFIG_K3_DM_FW)
- U_BOOT_DRIVER(ti_sci_dm) = {
- .name = "ti_sci_dm",
- .id = UCLASS_FIRMWARE,
- .of_match = ti_sci_dm_ids,
- .probe = ti_sci_dm_probe,
- .priv_auto = sizeof(struct ti_sci_info),
- };
- #endif
|