0

Ok, here's what I'm doing.

  1. Get vendor ID and device ID of my SMBus and use it in pci_get_dev() to get pdev.
  2. Get the dev using &pdev->dev and save it to struct device *smbus_dev
  3. Map a page to DMA using dma_map_page(smbus_dev, pfn_to_page(PHYS_PFN((unsigned long)addr)), offset_in_page(addr), Size, DMA_TO_DEVICE).

So (3) gives me back a dma_addr_t that I'm naming dma_handle.

On another place (edk2 uefi) I have SmBusLib implemented, and I'm able to use SmBusReadDataByte(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL). Problem is when I use my dma_handle as the argument SmBusAddress the function returns an error claiming that (((SmBusAddress) >> 16) & 0x3f) != 0 and for some reason I don't not why it should not be.

So at this point I'm guessing dma_addr_t returned from dma_map_page() is not equal the SmBusAddress I'm supposed to pass. Anyone knows if that is correct? And how am I supposed to "convert" dma_addr_t to SmBusAddress?

Allan Almeida
  • 13
  • 1
  • 5
  • 1
    Since SmBusReadDataByte is not part of the kernel, only you know what arguments it takes. By the name, I would guess it wants a 10-bit SMB device address, while you are giving it a DMA address in RAM. – stark Dec 22 '22 at 18:28

0 Answers0