|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( i$ @# d- z. @#include <linux/init.h>' y+ W3 ]- }& M+ H- m
#include <linux/module.h>, R7 o: A4 [' \: ^
#include <linux/kernel.h>% H3 }% O( f! o) S$ G: @" J6 v
#include <linux/types.h>0 Q; L6 @$ R l4 _$ U) S
#include <linux/gpio.h>( f0 ]7 A9 ^9 A9 D) R
#include <linux/leds.h>
: _1 Q6 |! e5 {, q- ]1 w# ^4 j#include <linux/platform_device.h>
l1 }- |8 w4 A, B. u; J7 c6 C# {3 o: f) v& \( ~) [5 m
#include <asm/mach-types.h>
7 `; m$ D6 l' h U#include <asm/mach/arch.h>3 v2 k) U: e& L; e% B/ \( n; x2 u: v
#include <mach/da8xx.h>, W6 B3 x. [0 o0 g
#include <mach/mux.h>
6 N6 [7 c4 ?6 }
4 J3 F# a2 r. H; C& ]0 L; u4 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 P9 [* [' f+ G* a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): ~, w2 o$ Y% l. f& D4 ?- u. i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 |4 n2 @' s0 N: v/ R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 J: T! O+ F3 }" |+ w5 y3 W. E7 ], B# U8 Y; F$ m3 A
/* assign the tl som board LED-GPIOs*/
$ O3 o2 ?( K" S1 y& q4 V9 _ estatic const short da850_evm_tl_user_led_pins[] = {' @$ E! Z' g# f- ]# } s7 J
/* These pins are definition at <mach/mux.h> file */
# C" n$ G( u5 ~% k4 n( A! p% q7 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 U. S/ q' Y. u8 L- j' O) {, L2 b -1
; I" _% J" m; \) q};9 x; ]; V t$ H, @# a6 z
3 D4 W! z+ c! x6 }
static struct gpio_led da850_evm_tl_leds[] = {2 S' r, ~5 F3 z
{
$ O/ D- h4 T8 F .active_low = 0,8 p$ T0 ^; s% m# E
.gpio = DA850_USER_LED0,9 R h* i) v$ {9 y+ X
.name = "user_led0",/ e* L; d5 C7 H- k2 d
.default_trigger = "default-on",6 n$ s8 b# i( i, K9 s
},1 [5 s8 F* Y, \
{
/ H9 U2 j+ v0 `" l" I$ ] .active_low = 0,
|: K5 s) x" A9 T/ b$ c3 A' S/ r .gpio = DA850_USER_LED1,2 ~7 P8 [, A, w
.name = "user_led1",& S5 o v% V7 M0 [
.default_trigger = "default-on",- r( E0 ~, r- L2 Y5 C) n, Z
},
( s( M& m8 C. |" W4 S. ? {7 D8 a! r, Z$ m' k
.active_low = 0,
5 ~* Q- ~9 |- }; A .gpio = DA850_USER_LED2,
2 l. W; z, n. k1 \8 B .name = "user_led2",
- N: A @( V6 y* {' o .default_trigger = "default-on",
! E; o! P- E. i* r' J% x },
1 @6 I- n4 A9 y0 z2 q9 a; t( d {) ^0 `1 t/ u& [; M- D. \) B6 Y! V. E
.active_low = 0,
! b" p& Q1 }3 S( b: o; F6 Y2 ~% t .gpio = DA850_USER_LED3,- L' `& X5 z9 x1 ?, h
.name = "user_led3",
4 Z5 t+ @3 h& m2 E- i .default_trigger = "default-on",& w: R! ^) |0 \# m/ G
},& i8 c" _4 `7 b+ M
};
( c; D, n! X* I. l/ J' b" v3 v0 |1 S' h$ z9 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 x" V( j8 W& z .leds = da850_evm_tl_leds,
" f. P& @; J* @6 f3 d3 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) B) m' r/ I) Y& O: d# a};) I; J" {) e. |' H( d8 W' n0 v7 H
+ T& ]4 T! l3 N! s+ p9 Pstatic void led_dev_release(struct device *dev)8 M# t# V0 X6 S5 X+ i1 f
{
7 p) n/ l8 B$ W8 V};
0 j, V* D3 C8 u0 s+ R
! Y5 m" B$ A! t) C; o' O# ^static struct platform_device da850_evm_tl_leds_device = {
2 t; H8 t$ U4 U .name = "leds-gpio",4 J8 S9 g; Z) ~3 _; C0 f
.id = 1,
. ~$ g# f, `- S7 Z0 h .dev = {
3 E5 _# `# T9 @" `4 J .platform_data = &da850_evm_tl_leds_pdata,4 p! }+ X- Q8 ~: l+ ~
.release = led_dev_release,
- U$ _4 T* d6 A* }# c }/ D+ J# L$ n( m1 {5 i) v
};) B! B3 e: z9 ^; P$ ^: |. w
4 c0 K* Y. Q; r' s) S. l8 C" l
static int __init led_platform_init(void)9 M' x& o b" f% I
{
$ I* L E( o: m8 v1 r) [ int ret;' K8 x( p/ h( z# u/ m0 L
#if 0
$ U7 G! u2 Y" o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- m. n) j, b- ^5 q* { if (ret)3 g4 N: T. ? u" [4 J) Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( c1 p1 A, f! ?4 y "%d\n", ret);( U; u2 s8 s' ]. n1 S. n- F6 r
#endif
: S9 Z0 U x6 Y! L) y ret = platform_device_register(&da850_evm_tl_leds_device);/ X: a; _9 b* M4 g. F+ B8 f. H1 z( [
if (ret)
& \/ N" d6 G4 U- o; a pr_warning("Could not register som GPIO expander LEDS");
K! {4 f& j( V% ?4 H else
7 K# u$ R {, t4 ^9 B" Q5 H printk(KERN_INFO "LED register sucessful!\n");3 u& s- Z6 C8 v$ e) u( ~
9 P7 U# v1 A9 ]9 n
return ret;
+ m) L5 t( Z3 T, _8 @}
. J( _9 R2 `' G) ?! D# q) F0 k* g2 g- n% i! p8 G
static void __exit led_platform_exit(void)8 ]0 O! v" J; x% C
{7 c: c) y: {+ c0 m/ R
platform_device_unregister(&da850_evm_tl_leds_device);
" ?" G% U0 T" {/ y* F, |) ^
1 ]. v# d0 H0 P% \5 w" I8 A2 D printk(KERN_INFO "LED unregister!\n");
- _) \9 G% A' V( ^6 S9 T6 w; L}5 H7 w0 I7 p( I r
; h- L# p& t( q# ~1 J( i- Omodule_init(led_platform_init);
$ E. Z) X& z( p2 b4 v" n) Q1 `module_exit(led_platform_exit);
. j( u6 X& L6 m% z7 K! ~% k6 D- G0 p
MODULE_DESCRIPTION("Led platform driver");
) ]6 z: u" E7 eMODULE_AUTHOR("Tronlong");" ]* {. k8 i2 t) r
MODULE_LICENSE("GPL"); Q+ s) ^! S' J. }
! d' j0 n) @& t% _
|
|