|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' B1 f5 w; |$ Z( n" f
#include <linux/init.h>8 V6 B) l+ A$ |" C4 d0 y' K3 o
#include <linux/module.h>
! p4 R+ z1 Y/ v, N1 @! Q#include <linux/kernel.h>
. J; G& y9 a4 o3 I& O) W! E: y#include <linux/types.h>
, U. g% m1 J5 i- S3 T! J3 L#include <linux/gpio.h>; V. U; @: F% O' p" D7 t
#include <linux/leds.h>
- V' O8 y/ }4 ] a$ \#include <linux/platform_device.h>
- @' r7 G% S/ @. |& _) k. \; O2 g$ S6 j8 B5 @7 V. q: @$ @" q
#include <asm/mach-types.h>8 Q( _7 Q5 t* k) Q$ p
#include <asm/mach/arch.h>+ _7 ]2 B. Z$ I* ]& T8 H7 f
#include <mach/da8xx.h>: r* d8 P( I) R) j4 I: ~, c
#include <mach/mux.h>& W+ M4 a, F4 ^- {( f
- q* G1 ^" w: v5 H Q3 R2 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 B: o" I5 b) A- d& r* C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ ]# s1 X6 i o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; R4 p9 V) M7 f1 H+ I3 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: R/ h/ n" U" _& A* g
1 e0 s1 d. I1 i& a$ l' l/* assign the tl som board LED-GPIOs*/& C) L- F4 q, j
static const short da850_evm_tl_user_led_pins[] = {5 E$ K# N6 Y! D3 Q' b
/* These pins are definition at <mach/mux.h> file */
- i! f! X! _2 f6 D% w/ \2 F' v7 f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& X. ~. l: F4 `* \9 S: B. [3 M -1
& n5 Z: ^5 C+ c/ ^5 `};
5 \! g7 A2 @8 Z* ^; K# r& V
3 x+ Y H: F" q4 |7 ]" Z' E; astatic struct gpio_led da850_evm_tl_leds[] = {+ Y- Y8 y5 j$ k$ ~1 V- ~
{% o1 }9 Z; a3 a! L
.active_low = 0,
% b3 \" a) x! i) k. H .gpio = DA850_USER_LED0,! h& A& z* C8 G- t; A7 ~! C
.name = "user_led0",. d6 U* n f/ q, {& {/ ?
.default_trigger = "default-on",- A5 \) ]3 M- G4 F6 y
},6 E" h% R$ A( |& G1 Y
{1 g9 K' ?; s: D) Q: i
.active_low = 0,) z b5 @& j, N# @9 w9 N$ Z) X; K8 h
.gpio = DA850_USER_LED1,
$ _4 K3 e- l- N8 ?2 ` .name = "user_led1",# R. R5 j" T5 w& a& G0 H
.default_trigger = "default-on",
" ^* x# N# x# u# g9 t0 _3 q },, }3 k! m, ~( l" f, B
{
: |6 `6 F& @3 _; B/ i .active_low = 0,
- h, ^( ?" T0 f .gpio = DA850_USER_LED2," |- {1 ~. Z& F- }: {7 Q
.name = "user_led2",
# U; D6 W; H: b( {+ H9 p( ^ .default_trigger = "default-on",
$ J' N1 U1 E7 u- u: u },* a' P6 Z3 r( D/ |; x. y
{* t1 r) V6 C3 o7 ^& q5 i+ k; }2 r
.active_low = 0,+ U( \+ T9 Y; S- w4 ^ m
.gpio = DA850_USER_LED3,
t' H$ ?: `* H6 E% S. W .name = "user_led3",
+ b% {3 B1 N8 F" f7 \ .default_trigger = "default-on",
h- Y' u; h1 b. W2 J& T* @9 c },+ j, _. m( }6 _% Y- [
};) J X6 ~ F7 J4 s" P: @8 _ U2 r
3 Z( w4 Z, s6 C# Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- `7 ^- r! Z( d! r; u
.leds = da850_evm_tl_leds,; b1 x/ ?5 |8 x$ E$ c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 A9 W( h% B; w, x) r2 {- }% k. o" y
};+ c- Z5 W% q* |2 Q5 ?4 P; w
8 }9 J& b! t7 E( D& r% \- t
static void led_dev_release(struct device *dev)
8 N% i' x! K8 L& V. u D# D( v{
, M- W5 P7 q, b4 ^7 c1 [};
( A- Z; a# L4 d& h3 R- v- H5 Q8 M, t
static struct platform_device da850_evm_tl_leds_device = {" p2 Z3 Y' h9 W" \
.name = "leds-gpio",
0 Q' k- J/ R9 w C( N' j .id = 1,# ^8 c' t7 F/ c4 Q+ b# h
.dev = {
, x+ }4 V( {( u- h& W .platform_data = &da850_evm_tl_leds_pdata,& f3 r- I- H( b4 f: ~
.release = led_dev_release,
5 d( j4 n0 V, E+ }0 n" x }: i k8 a- Q6 ?+ ?! ^
};$ H: A4 o* E" l& U3 V K" v
7 k' ]# O* L' Q. H+ W. kstatic int __init led_platform_init(void)
8 z2 D- K s0 X1 b$ `{, s+ V' ?& I$ j. g2 a9 P- Z
int ret;
, D! V5 n. u# v( n( R# D#if 0; u: e& J1 M( [ H9 ^/ V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! g' s% F$ g2 g( M6 z4 ~- Y* X- S% S if (ret)
% m1 e- H0 `! k( m# p1 O' l, P7 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* H4 _( [9 x6 `' ~
"%d\n", ret);
, u. K7 \! w+ z#endif
i( F% H3 Q. p% M0 e! U) |# j5 s ret = platform_device_register(&da850_evm_tl_leds_device);& D& Y6 E- k! G- g
if (ret)1 f ~: p ~1 I E; d X
pr_warning("Could not register som GPIO expander LEDS");' h P* ] J3 G! }
else7 a9 w6 f9 i( P {
printk(KERN_INFO "LED register sucessful!\n");
4 F7 F! k. z; V0 N' p2 |0 H9 i9 x8 w; j7 N
return ret;+ X1 {9 N( g% I; d; y ?
}8 V$ t" I$ A* J% H! }
0 P A* m! @% ]9 j: {0 T/ Z
static void __exit led_platform_exit(void)3 `' C5 _) I, C
{
8 q6 Y k _4 ~' |: l9 a platform_device_unregister(&da850_evm_tl_leds_device);# x3 _9 k+ R3 U# \& H7 D
9 r9 _' v8 ^/ a0 b' |0 h
printk(KERN_INFO "LED unregister!\n");* h+ y) e4 P( g: G4 g. H! {
}- h+ X W. T2 e2 O# W
5 v- J, |( S# h f. m& W2 L' z
module_init(led_platform_init);4 I( z/ p2 ?- j. B, b
module_exit(led_platform_exit);/ l3 t# F* e' s9 j; K+ h- H4 {
+ Z) { ^* j( v$ a2 ?4 S6 F5 \MODULE_DESCRIPTION("Led platform driver");+ Z6 [/ Q, h, h/ ^" R
MODULE_AUTHOR("Tronlong");! N9 j& f! @8 q9 e
MODULE_LICENSE("GPL");
( w3 z7 D" a5 A0 h; k! I
. q/ U- t9 ~) p, i7 B |
|