iommu: msm: Add driver for IOMMU PMU

Some IOMMU's have a Performance Monitoring Unit (PMU). The PMU can be
used to monitor the performance of the IOMMU such as TLB hit rate
percentage. Each IOMMU that supports PMU has several counters that
can be individually configured to count different events.
A collection of counters is managed in a counter group. A PMU
might have one or more counter groups with one or more counters
in each group.

A counter can be configured to monitor certain events called event
classes. A PMU can support a set of standard event classes
such as TLB refill and access count in addition to implementation
defined event classes.

The configuration (number of counter groups, the number of counters
in each group, and which standard event classes are supported) of
each PMU is read from the hardware during initialization of the
driver.

A debugfs interface is exposed allowing configuration of the
counters for each IOMMU instance. The debugfs interface for PMU
is organized in the following manner:

iommu
|-- <iommu_name1>
|    |-- available_event_classes
|    |-- enable_counters
|    |-- reset_counters
|    |-- group0
|    |    |-- counter0
|    |    |    |-- current_event_class
|    |    |    +-- value
|    |    |-- counter1
|    |    |    |-- current_event_class
|    |    |    +-- value
|    |    |-- ...
|    |    +-- counter<m>
|    |-- group1
|    |    |-- counter0
|    |    |    |-- current_event_class
|    |    |    +-- value
|    |    |-- counter1
|    |    |    |-- current_event_class
|    |    |    +-- value
|    |    |-- ...
|    |    +-- counter<m>
|    +-- group<n>
|-- <iommu_name2>
|-- ...
+-- <iommu_nameX>

Doing a cat on "available_event_classes" will give a list of
all the event classes that this IOMMU supports. Echoing a 1
to enable_counters will enable all the counters in all the groups
for the IOMMU. Echoing a 0 will turn the counters off.
Echoing a 1 to reset_counters will reset all the counters for this
IOMMU. The event class for each counter can be set by echoing the
corrsponding event class name or number to the "current_event_class"
file. Each counter can be read by doing a cat on each "value" file.

Change-Id: Ifceb93a06d446815555cc23e8527681d5e7e7b86
Signed-off-by: Hanumant Singh <hanumant@codeaurora.org>
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
5 files changed