Ok, here's what I'm doing.
- Get vendor ID and device ID of my SMBus and use it in
pci_get_dev()
to get pdev. - Get the dev using
&pdev->dev
and save it tostruct device *smbus_dev
- 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
?