|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- ^$ V7 o3 j: ]) y9 d
#include <linux/init.h>
2 j5 i1 h8 ]# R$ L#include <linux/module.h>7 u" n1 x7 z% b9 O
#include <linux/kernel.h>5 l2 @6 X8 @; z" C* g, `" r0 V
#include <linux/types.h>
$ A9 @4 S9 _% x) _7 I$ b* [#include <linux/gpio.h>
0 }3 P2 a+ i0 b6 X$ n6 P#include <linux/leds.h>, Y/ S+ G4 K0 @( k- L
#include <linux/platform_device.h>
q; M0 z1 m4 ]3 F
' D! j) f+ P8 t0 A# N#include <asm/mach-types.h>2 p/ p9 |$ m% ?" a: a
#include <asm/mach/arch.h>5 d( Q1 }8 I9 w. |, q& ]+ v X
#include <mach/da8xx.h>
' P& ~6 J6 e( d. A1 \! G. p0 h#include <mach/mux.h>
5 b" N! t! u/ Y# |0 D* |; q1 f) T. O2 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ _7 [; \, o4 E+ @1 e- z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 t* ]4 P# C. F0 L/ [3 M3 V' y3 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, B5 B* y0 o7 @. q: C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) O* X0 T/ `4 C" V6 |$ o2 l& F" t' w9 Q( J% t: J$ f
/* assign the tl som board LED-GPIOs*/
* S9 W9 W( ~, z5 A# d8 `+ sstatic const short da850_evm_tl_user_led_pins[] = {
2 |, U4 p% x7 u5 P /* These pins are definition at <mach/mux.h> file */
- L5 k2 @3 G# k6 B+ N. L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& U3 g8 C9 p& I' S5 A
-13 F+ _8 {2 E% }& C+ e" @( U$ k$ d
};; n( T/ R" ^; f+ _1 t& s
8 T. |/ ]3 q0 }$ m2 }2 ^1 @- Q$ A$ \static struct gpio_led da850_evm_tl_leds[] = {
2 \, o# ?, G0 J+ o# S3 K- X {3 @. \1 G! U( _- ]
.active_low = 0,9 P4 k# ^7 z) r& |* D) f# Z
.gpio = DA850_USER_LED0,
7 \4 H$ u5 u# e/ t2 }! J .name = "user_led0",
p. U7 L* M7 Y9 Z2 P5 F .default_trigger = "default-on",; L' C6 i0 O' e5 u8 c
},
/ |; A5 Z. R; y# a; k {: J; t( c: q% q0 L# g( W# X
.active_low = 0,
9 }0 d8 R n' q2 K, Y( h .gpio = DA850_USER_LED1,
6 F+ [0 {! T$ ]: h( C T .name = "user_led1",
# f/ U" s' q2 r1 m .default_trigger = "default-on",; C1 W8 x1 ?, s9 W) c- h, C$ m
},
4 f# |# K/ A9 f {+ Z1 r; o3 P$ L2 e
.active_low = 0,+ Z' ~) J. f& m
.gpio = DA850_USER_LED2,
8 j2 u$ O* q, n .name = "user_led2",% ^4 `( ?0 C6 T' A
.default_trigger = "default-on",
9 m" {1 P1 F: B/ S6 J/ Q },
! I$ p" v+ K: G9 Z3 g9 H: Y& b {
1 I2 g" k8 }, b& z: W; ] .active_low = 0,
- U3 e/ h7 n, q( p9 H .gpio = DA850_USER_LED3,
# M5 K7 H, F* |9 W) @0 P9 _ .name = "user_led3",
! h5 }! e5 p' y! x% ~! |: @* ] .default_trigger = "default-on",
2 @ ~, ?2 M" M$ ~0 v/ ^ },0 g. H. {- p4 S
};5 w |% C( v1 k
% r, D* e+ c4 C3 }9 K6 d' W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 `) K0 L. H* F' x X( {
.leds = da850_evm_tl_leds,- l+ m; z$ b5 G& k' T3 l" Y6 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," P& n# b0 R6 J" X8 }3 I
};
8 y* p& z* _* A. d3 ?7 \$ M4 H4 g# N5 z5 m% B
static void led_dev_release(struct device *dev)8 V: g! |+ k; t; P1 l
{8 d- ~- { J. T- ]" V6 |
};6 R( M0 I4 v0 d; u3 D( m6 ~
: [, ~, F1 \: I5 \1 m4 x. |5 C C, istatic struct platform_device da850_evm_tl_leds_device = {
: P* x; V: u$ d; z8 x, @# l .name = "leds-gpio",
; f t9 Q- t9 d .id = 1,
, y4 c5 S' R, m) G. j( G5 \ .dev = {
. r3 n- P( N1 V' Y( Y .platform_data = &da850_evm_tl_leds_pdata,
5 y% R; q% O% k& K( _ .release = led_dev_release,$ B5 a) t3 g. f" I1 `/ b# ?0 \4 {
}
% j" }- w% u9 f6 d}; C# e4 H7 j7 P4 c, j
* a5 V6 X7 W) Z f& m1 D1 c: J+ m' Jstatic int __init led_platform_init(void)
9 n( T5 t% ^4 Z& r) U8 N- h{
6 g& _' ` U- H" O9 B int ret;' t+ y2 c! y) Y" o7 u; _
#if 0
. m; A0 ^; A% K) b0 L- S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 I1 ?) ?) C/ ~" r0 Y! |. t4 ] if (ret)
- U6 Q0 t' W# j, A+ [8 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 ?" K2 M2 X% w# V5 I0 O" W5 t6 K
"%d\n", ret);
6 O/ C$ S0 s* X% {" J( d+ R! V#endif9 G* S) L; X7 B8 C6 o* L- h
ret = platform_device_register(&da850_evm_tl_leds_device);2 ?5 y2 q2 Q1 A+ M1 }- R
if (ret)
/ v9 ?+ M4 _3 w1 x7 R/ a' G a4 z6 K& X4 H, | pr_warning("Could not register som GPIO expander LEDS");+ l- ~" ` n1 r: P. B! F+ [' ]6 f
else
3 g9 O: G1 `, ^$ H$ i printk(KERN_INFO "LED register sucessful!\n");
, k: s {& p2 M' Q1 e: H
/ o# ~5 r" G, y return ret;
8 Z; H* b2 [' F1 f$ f. T; Z$ v}
, C% M) p# Y1 B; F5 X2 \6 j9 }& |7 X' n% X9 g' a5 r; z
static void __exit led_platform_exit(void)/ A0 x" l* B6 S6 Z
{# |0 h; Y9 N7 l6 U5 i
platform_device_unregister(&da850_evm_tl_leds_device);) N# v! i; m$ s+ h, d7 ~0 _
( _3 X0 ]' O- |3 A( Q+ X printk(KERN_INFO "LED unregister!\n");
_, I( Z6 B4 v4 q. ~2 Y}
3 u+ T# q& s9 v' K" G! d" U8 f! a# ~1 t* o# A7 W
module_init(led_platform_init);% }9 Q7 y: P# E8 s- e/ X, S) x
module_exit(led_platform_exit);+ |3 |# Y) l, z3 v- D. C4 v- ~
' S9 p" v+ V4 @/ l VMODULE_DESCRIPTION("Led platform driver");% z( [. {* t! {4 ^
MODULE_AUTHOR("Tronlong");* B' K# a P3 \9 f$ m) M& v0 d0 m \6 C
MODULE_LICENSE("GPL");) Q1 [7 O0 Z" d) D+ w: C. N! m& {
- p6 b F. N/ t2 {) b. L# \* K
|
|