Commit d1b1110f authored by David S. Miller's avatar David S. Miller

Merge branch 'mvpp2-Armada-7k-8k-PP2-ACPI-support'

Marcin Wojtas says:

====================
Armada 7k/8k PP2 ACPI support

I quickly resend the series, thanks to Antoine Tenart's remark,
who spotted !CONFIG_ACPI compilation issue after introducing
the new fwnode_irq_get() routine. Please see the details in the changelog
below and the 3/7 commit log.

mvpp2 driver can work with the ACPI representation, as exposed
on a public branch:
https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/marvell-armada-wip
It was compiled together with the most recent Tianocore EDK2 revision.
Please refer to the firmware build instruction on MacchiatoBin board:
http://wiki.macchiatobin.net/tiki-index.php?page=Build+from+source+-+UEFI+EDK+II

ACPI representation of PP2 controllers (withouth PHY support) can
be viewed in the github:
* MacchiatoBin:
https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/blob/71ae395da1661374b0f07d1602afb1eee56e9794/Platforms/Marvell/Armada/AcpiTables/Armada80x0McBin/Dsdt.asl#L201

* Armada 7040 DB:
https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/blob/71ae395da1661374b0f07d1602afb1eee56e9794/Platforms/Marvell/Armada/AcpiTables/Armada70x0/Dsdt.asl#L131

I will appreciate any comments or remarks.

Best regards,
Marcin

Changelog:
v3 -> v4:
* 3/7
    - add new macro (ACPI_HANDLE_FWNODE) and fix
      compilation with !CONFIG_ACPI
    - extend commit log and mention usability of fwnode_irq_get
      for the child nodes as well

v2 -> v3:
* 1/7, 2/7
    - Add Rafael's Acked-by's
* 3/7, 4/7
    - New patches
* 6/7, 7/7
    - Update driver with new helper routines usage
    - Improve commit log.

v1 -> v2:
* Remove MDIO patches
* Use PP2 ports only with link interrupts
* Release second region resources in mvpp2 driver (code moved from
  mvmdio), as explained in details in 5/5 commit message.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e0b4ed01 a75edc7c
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_graph.h> #include <linux/of_graph.h>
#include <linux/of_irq.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/phy.h> #include <linux/phy.h>
...@@ -996,6 +997,32 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode, ...@@ -996,6 +997,32 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
} }
EXPORT_SYMBOL_GPL(fwnode_get_next_child_node); EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
/**
* fwnode_get_next_available_child_node - Return the next
* available child node handle for a node
* @fwnode: Firmware node to find the next child node for.
* @child: Handle to one of the node's child nodes or a %NULL handle.
*/
struct fwnode_handle *
fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
struct fwnode_handle *child)
{
struct fwnode_handle *next_child = child;
if (!fwnode)
return NULL;
do {
next_child = fwnode_get_next_child_node(fwnode, next_child);
if (!next_child || fwnode_device_is_available(next_child))
break;
} while (next_child);
return next_child;
}
EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);
/** /**
* device_get_next_child_node - Return the next child node handle for a device * device_get_next_child_node - Return the next child node handle for a device
* @dev: Device to find the next child node for. * @dev: Device to find the next child node for.
...@@ -1126,21 +1153,21 @@ enum dev_dma_attr device_get_dma_attr(struct device *dev) ...@@ -1126,21 +1153,21 @@ enum dev_dma_attr device_get_dma_attr(struct device *dev)
EXPORT_SYMBOL_GPL(device_get_dma_attr); EXPORT_SYMBOL_GPL(device_get_dma_attr);
/** /**
* device_get_phy_mode - Get phy mode for given device * fwnode_get_phy_mode - Get phy mode for given firmware node
* @dev: Pointer to the given device * @fwnode: Pointer to the given node
* *
* The function gets phy interface string from property 'phy-mode' or * The function gets phy interface string from property 'phy-mode' or
* 'phy-connection-type', and return its index in phy_modes table, or errno in * 'phy-connection-type', and return its index in phy_modes table, or errno in
* error case. * error case.
*/ */
int device_get_phy_mode(struct device *dev) int fwnode_get_phy_mode(struct fwnode_handle *fwnode)
{ {
const char *pm; const char *pm;
int err, i; int err, i;
err = device_property_read_string(dev, "phy-mode", &pm); err = fwnode_property_read_string(fwnode, "phy-mode", &pm);
if (err < 0) if (err < 0)
err = device_property_read_string(dev, err = fwnode_property_read_string(fwnode,
"phy-connection-type", &pm); "phy-connection-type", &pm);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1151,13 +1178,27 @@ int device_get_phy_mode(struct device *dev) ...@@ -1151,13 +1178,27 @@ int device_get_phy_mode(struct device *dev)
return -ENODEV; return -ENODEV;
} }
EXPORT_SYMBOL_GPL(fwnode_get_phy_mode);
/**
* device_get_phy_mode - Get phy mode for given device
* @dev: Pointer to the given device
*
* The function gets phy interface string from property 'phy-mode' or
* 'phy-connection-type', and return its index in phy_modes table, or errno in
* error case.
*/
int device_get_phy_mode(struct device *dev)
{
return fwnode_get_phy_mode(dev_fwnode(dev));
}
EXPORT_SYMBOL_GPL(device_get_phy_mode); EXPORT_SYMBOL_GPL(device_get_phy_mode);
static void *device_get_mac_addr(struct device *dev, static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode,
const char *name, char *addr, const char *name, char *addr,
int alen) int alen)
{ {
int ret = device_property_read_u8_array(dev, name, addr, alen); int ret = fwnode_property_read_u8_array(fwnode, name, addr, alen);
if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr)) if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr))
return addr; return addr;
...@@ -1165,8 +1206,8 @@ static void *device_get_mac_addr(struct device *dev, ...@@ -1165,8 +1206,8 @@ static void *device_get_mac_addr(struct device *dev,
} }
/** /**
* device_get_mac_address - Get the MAC for a given device * fwnode_get_mac_address - Get the MAC from the firmware node
* @dev: Pointer to the device * @fwnode: Pointer to the firmware node
* @addr: Address of buffer to store the MAC in * @addr: Address of buffer to store the MAC in
* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN
* *
...@@ -1187,22 +1228,59 @@ static void *device_get_mac_addr(struct device *dev, ...@@ -1187,22 +1228,59 @@ static void *device_get_mac_addr(struct device *dev,
* In this case, the real MAC is in 'local-mac-address', and 'mac-address' * In this case, the real MAC is in 'local-mac-address', and 'mac-address'
* exists but is all zeros. * exists but is all zeros.
*/ */
void *device_get_mac_address(struct device *dev, char *addr, int alen) void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen)
{ {
char *res; char *res;
res = device_get_mac_addr(dev, "mac-address", addr, alen); res = fwnode_get_mac_addr(fwnode, "mac-address", addr, alen);
if (res) if (res)
return res; return res;
res = device_get_mac_addr(dev, "local-mac-address", addr, alen); res = fwnode_get_mac_addr(fwnode, "local-mac-address", addr, alen);
if (res) if (res)
return res; return res;
return device_get_mac_addr(dev, "address", addr, alen); return fwnode_get_mac_addr(fwnode, "address", addr, alen);
}
EXPORT_SYMBOL(fwnode_get_mac_address);
/**
* device_get_mac_address - Get the MAC for a given device
* @dev: Pointer to the device
* @addr: Address of buffer to store the MAC in
* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN
*/
void *device_get_mac_address(struct device *dev, char *addr, int alen)
{
return fwnode_get_mac_address(dev_fwnode(dev), addr, alen);
} }
EXPORT_SYMBOL(device_get_mac_address); EXPORT_SYMBOL(device_get_mac_address);
/**
* fwnode_irq_get - Get IRQ directly from a fwnode
* @fwnode: Pointer to the firmware node
* @index: Zero-based index of the IRQ
*
* Returns Linux IRQ number on success. Other values are determined
* accordingly to acpi_/of_ irq_get() operation.
*/
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index)
{
struct device_node *of_node = to_of_node(fwnode);
struct resource res;
int ret;
if (IS_ENABLED(CONFIG_OF) && of_node)
return of_irq_get(of_node, index);
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
if (ret)
return ret;
return res.start;
}
EXPORT_SYMBOL(fwnode_irq_get);
/** /**
* device_graph_get_next_endpoint - Get next endpoint firmware node * device_graph_get_next_endpoint - Get next endpoint firmware node
* @fwnode: Pointer to the parent firmware node * @fwnode: Pointer to the parent firmware node
......
This diff is collapsed.
...@@ -56,6 +56,8 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) ...@@ -56,6 +56,8 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
acpi_fwnode_handle(adev) : NULL) acpi_fwnode_handle(adev) : NULL)
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
#define ACPI_HANDLE_FWNODE(fwnode) \
acpi_device_handle(to_acpi_device_node(fwnode))
static inline struct fwnode_handle *acpi_alloc_fwnode_static(void) static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
{ {
...@@ -626,6 +628,7 @@ int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count) ...@@ -626,6 +628,7 @@ int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count)
#define ACPI_COMPANION(dev) (NULL) #define ACPI_COMPANION(dev) (NULL)
#define ACPI_COMPANION_SET(dev, adev) do { } while (0) #define ACPI_COMPANION_SET(dev, adev) do { } while (0)
#define ACPI_HANDLE(dev) (NULL) #define ACPI_HANDLE(dev) (NULL)
#define ACPI_HANDLE_FWNODE(fwnode) (NULL)
#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0), #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
struct fwnode_handle; struct fwnode_handle;
......
...@@ -83,11 +83,17 @@ struct fwnode_handle *fwnode_get_next_parent( ...@@ -83,11 +83,17 @@ struct fwnode_handle *fwnode_get_next_parent(
struct fwnode_handle *fwnode); struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_get_next_child_node( struct fwnode_handle *fwnode_get_next_child_node(
const struct fwnode_handle *fwnode, struct fwnode_handle *child); const struct fwnode_handle *fwnode, struct fwnode_handle *child);
struct fwnode_handle *fwnode_get_next_available_child_node(
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
#define fwnode_for_each_child_node(fwnode, child) \ #define fwnode_for_each_child_node(fwnode, child) \
for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
child = fwnode_get_next_child_node(fwnode, child)) child = fwnode_get_next_child_node(fwnode, child))
#define fwnode_for_each_available_child_node(fwnode, child) \
for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
child = fwnode_get_next_available_child_node(fwnode, child))
struct fwnode_handle *device_get_next_child_node( struct fwnode_handle *device_get_next_child_node(
struct device *dev, struct fwnode_handle *child); struct device *dev, struct fwnode_handle *child);
...@@ -103,6 +109,8 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev, ...@@ -103,6 +109,8 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev,
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
void fwnode_handle_put(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode);
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
unsigned int device_get_child_node_count(struct device *dev); unsigned int device_get_child_node_count(struct device *dev);
static inline bool device_property_read_bool(struct device *dev, static inline bool device_property_read_bool(struct device *dev,
...@@ -279,6 +287,9 @@ int device_get_phy_mode(struct device *dev); ...@@ -279,6 +287,9 @@ int device_get_phy_mode(struct device *dev);
void *device_get_mac_address(struct device *dev, char *addr, int alen); void *device_get_mac_address(struct device *dev, char *addr, int alen);
int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
void *fwnode_get_mac_address(struct fwnode_handle *fwnode,
char *addr, int alen);
struct fwnode_handle *fwnode_graph_get_next_endpoint( struct fwnode_handle *fwnode_graph_get_next_endpoint(
const struct fwnode_handle *fwnode, struct fwnode_handle *prev); const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
struct fwnode_handle * struct fwnode_handle *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment