···898898 adev->dummy_page.page = NULL;899899}900900901901-902902-/* ATOM accessor methods */903903-/*904904- * ATOM is an interpreted byte code stored in tables in the vbios. The905905- * driver registers callbacks to access registers and the interpreter906906- * in the driver parses the tables and executes then to program specific907907- * actions (set display modes, asic init, etc.). See amdgpu_atombios.c,908908- * atombios.h, and atom.c909909- */910910-911911-/**912912- * cail_pll_read - read PLL register913913- *914914- * @info: atom card_info pointer915915- * @reg: PLL register offset916916- *917917- * Provides a PLL register accessor for the atom interpreter (r4xx+).918918- * Returns the value of the PLL register.919919- */920920-static uint32_t cail_pll_read(struct card_info *info, uint32_t reg)921921-{922922- return 0;923923-}924924-925925-/**926926- * cail_pll_write - write PLL register927927- *928928- * @info: atom card_info pointer929929- * @reg: PLL register offset930930- * @val: value to write to the pll register931931- *932932- * Provides a PLL register accessor for the atom interpreter (r4xx+).933933- */934934-static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val)935935-{936936-937937-}938938-939939-/**940940- * cail_mc_read - read MC (Memory Controller) register941941- *942942- * @info: atom card_info pointer943943- * @reg: MC register offset944944- *945945- * Provides an MC register accessor for the atom interpreter (r4xx+).946946- * Returns the value of the MC register.947947- */948948-static uint32_t cail_mc_read(struct card_info *info, uint32_t reg)949949-{950950- return 0;951951-}952952-953953-/**954954- * cail_mc_write - write MC (Memory Controller) register955955- *956956- * @info: atom card_info pointer957957- * @reg: MC register offset958958- * @val: value to write to the pll register959959- *960960- * Provides a MC register accessor for the atom interpreter (r4xx+).961961- */962962-static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val)963963-{964964-965965-}966966-967967-/**968968- * cail_reg_write - write MMIO register969969- *970970- * @info: atom card_info pointer971971- * @reg: MMIO register offset972972- * @val: value to write to the pll register973973- *974974- * Provides a MMIO register accessor for the atom interpreter (r4xx+).975975- */976976-static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val)977977-{978978- struct amdgpu_device *adev = info->dev->dev_private;979979-980980- WREG32(reg, val);981981-}982982-983983-/**984984- * cail_reg_read - read MMIO register985985- *986986- * @info: atom card_info pointer987987- * @reg: MMIO register offset988988- *989989- * Provides an MMIO register accessor for the atom interpreter (r4xx+).990990- * Returns the value of the MMIO register.991991- */992992-static uint32_t cail_reg_read(struct card_info *info, uint32_t reg)993993-{994994- struct amdgpu_device *adev = info->dev->dev_private;995995- uint32_t r;996996-997997- r = RREG32(reg);998998- return r;999999-}10001000-10011001-/**10021002- * cail_ioreg_write - write IO register10031003- *10041004- * @info: atom card_info pointer10051005- * @reg: IO register offset10061006- * @val: value to write to the pll register10071007- *10081008- * Provides a IO register accessor for the atom interpreter (r4xx+).10091009- */10101010-static void cail_ioreg_write(struct card_info *info, uint32_t reg, uint32_t val)10111011-{10121012- struct amdgpu_device *adev = info->dev->dev_private;10131013-10141014- WREG32_IO(reg, val);10151015-}10161016-10171017-/**10181018- * cail_ioreg_read - read IO register10191019- *10201020- * @info: atom card_info pointer10211021- * @reg: IO register offset10221022- *10231023- * Provides an IO register accessor for the atom interpreter (r4xx+).10241024- * Returns the value of the IO register.10251025- */10261026-static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)10271027-{10281028- struct amdgpu_device *adev = info->dev->dev_private;10291029- uint32_t r;10301030-10311031- r = RREG32_IO(reg);10321032- return r;10331033-}10341034-10351035-static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,10361036- struct device_attribute *attr,10371037- char *buf)10381038-{10391039- struct drm_device *ddev = dev_get_drvdata(dev);10401040- struct amdgpu_device *adev = ddev->dev_private;10411041- struct atom_context *ctx = adev->mode_info.atom_context;10421042-10431043- return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version);10441044-}10451045-10461046-static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,10471047- NULL);10481048-10491049-/**10501050- * amdgpu_atombios_fini - free the driver info and callbacks for atombios10511051- *10521052- * @adev: amdgpu_device pointer10531053- *10541054- * Frees the driver info and register access callbacks for the ATOM10551055- * interpreter (r4xx+).10561056- * Called at driver shutdown.10571057- */10581058-static void amdgpu_atombios_fini(struct amdgpu_device *adev)10591059-{10601060- if (adev->mode_info.atom_context) {10611061- kfree(adev->mode_info.atom_context->scratch);10621062- kfree(adev->mode_info.atom_context->iio);10631063- }10641064- kfree(adev->mode_info.atom_context);10651065- adev->mode_info.atom_context = NULL;10661066- kfree(adev->mode_info.atom_card_info);10671067- adev->mode_info.atom_card_info = NULL;10681068- device_remove_file(adev->dev, &dev_attr_vbios_version);10691069-}10701070-10711071-/**10721072- * amdgpu_atombios_init - init the driver info and callbacks for atombios10731073- *10741074- * @adev: amdgpu_device pointer10751075- *10761076- * Initializes the driver info and register access callbacks for the10771077- * ATOM interpreter (r4xx+).10781078- * Returns 0 on sucess, -ENOMEM on failure.10791079- * Called at driver startup.10801080- */10811081-static int amdgpu_atombios_init(struct amdgpu_device *adev)10821082-{10831083- struct card_info *atom_card_info =10841084- kzalloc(sizeof(struct card_info), GFP_KERNEL);10851085- int ret;10861086-10871087- if (!atom_card_info)10881088- return -ENOMEM;10891089-10901090- adev->mode_info.atom_card_info = atom_card_info;10911091- atom_card_info->dev = adev->ddev;10921092- atom_card_info->reg_read = cail_reg_read;10931093- atom_card_info->reg_write = cail_reg_write;10941094- /* needed for iio ops */10951095- if (adev->rio_mem) {10961096- atom_card_info->ioreg_read = cail_ioreg_read;10971097- atom_card_info->ioreg_write = cail_ioreg_write;10981098- } else {10991099- DRM_DEBUG("PCI I/O BAR is not found. Using MMIO to access ATOM BIOS\n");11001100- atom_card_info->ioreg_read = cail_reg_read;11011101- atom_card_info->ioreg_write = cail_reg_write;11021102- }11031103- atom_card_info->mc_read = cail_mc_read;11041104- atom_card_info->mc_write = cail_mc_write;11051105- atom_card_info->pll_read = cail_pll_read;11061106- atom_card_info->pll_write = cail_pll_write;11071107-11081108- adev->mode_info.atom_context = amdgpu_atom_parse(atom_card_info, adev->bios);11091109- if (!adev->mode_info.atom_context) {11101110- amdgpu_atombios_fini(adev);11111111- return -ENOMEM;11121112- }11131113-11141114- mutex_init(&adev->mode_info.atom_context->mutex);11151115- if (adev->is_atom_fw) {11161116- amdgpu_atomfirmware_scratch_regs_init(adev);11171117- amdgpu_atomfirmware_allocate_fb_scratch(adev);11181118- } else {11191119- amdgpu_atombios_scratch_regs_init(adev);11201120- amdgpu_atombios_allocate_fb_scratch(adev);11211121- }11221122-11231123- ret = device_create_file(adev->dev, &dev_attr_vbios_version);11241124- if (ret) {11251125- DRM_ERROR("Failed to create device file for VBIOS version\n");11261126- return ret;11271127- }11281128-11291129- return 0;11301130-}11311131-1132901/* if we get transitioned to only one device, take VGA back */1133902/**1134903 * amdgpu_vga_set_decode - enable/disable vga decode