|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ a: g! J" h3 k$ ^
#include <linux/init.h>( h x9 E4 u5 N* N) I# k- {
#include <linux/module.h>
. V8 {( G$ }- A% |: Y4 Q. J+ Z#include <linux/kernel.h>+ J3 i9 ?4 o) p! F' Z z
#include <linux/types.h>! O6 q9 [" a y( v
#include <linux/gpio.h>+ ^5 G+ a! z1 q6 ]8 L$ I8 ?
#include <linux/leds.h>
& m) f, O+ p ~3 z#include <linux/platform_device.h>! Q3 n' D) g5 [
7 S7 w* J; H6 L* D4 I6 P/ P#include <asm/mach-types.h>
2 o9 p; d9 ~; Y- L/ f* ]8 s#include <asm/mach/arch.h>
" |3 @0 `# v# ~; }9 x#include <mach/da8xx.h>" }- T8 N( B2 ?* [1 r
#include <mach/mux.h>( y1 I* t/ }' G( E$ f* u
6 k8 |; C- P& X# `) g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* B6 q }1 E/ Y( K& s' ~$ z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): P* f6 B% K- ~) l7 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; w8 k. P5 H7 o+ D4 @5 r: B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 H2 A5 s8 y- S2 E8 O& W6 C+ [. K$ V4 s+ [! C7 Y9 O- l
/* assign the tl som board LED-GPIOs*// r: L* C: X$ G4 a6 P2 C/ s
static const short da850_evm_tl_user_led_pins[] = {
, P! G7 t3 u9 F$ a& |9 ~8 N /* These pins are definition at <mach/mux.h> file */
P& X9 z/ P1 X1 {9 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 r, E0 C# g( z4 N4 r
-1- V9 o' C! ]" }
};
2 m u& P" n; z6 i9 w2 e0 @% u( d
4 z1 d Z: {6 [0 O. b* E7 gstatic struct gpio_led da850_evm_tl_leds[] = {: o( `+ c1 V/ ~' m& u# r5 M
{6 T+ n. @8 X+ v
.active_low = 0,
/ \1 H4 a' t1 r2 Z( |+ c0 l) j .gpio = DA850_USER_LED0,
! s+ a# H3 C" J% O, @9 L) i8 t .name = "user_led0",, ~, g5 X0 k" U! {1 K
.default_trigger = "default-on",
$ ^1 L& V+ w6 w- v/ x( Q },
9 I& T; }. c8 B$ K ^ {
& U0 d$ B* r5 r9 a) a0 F8 Z, ~5 J2 r .active_low = 0,
! k* `6 x2 f( S" [8 n8 [/ P .gpio = DA850_USER_LED1,- ^7 P$ S+ ^2 n& A
.name = "user_led1"," a) `% S. s; q- P- H8 T
.default_trigger = "default-on",: O5 X9 m3 t! H" ^! ?, \1 J A
},
) |/ z! Y8 o, T* A: d3 t" F {/ n5 P1 g# l& w& E% j) X
.active_low = 0,; D7 j5 _0 ]; v3 S! W" T7 g8 x
.gpio = DA850_USER_LED2,
& ?" Y" s( x, F8 U .name = "user_led2",& d! Z/ S# U; C: E2 U% O, ?
.default_trigger = "default-on",
Y& n( M4 ^/ F/ ` },
6 N6 W$ ? x8 D) R {
5 U7 ?* V& R$ q7 O; d0 n .active_low = 0,
, t- F4 t( N. f1 q .gpio = DA850_USER_LED3,
# \2 T! v6 j( G$ E) A8 U .name = "user_led3",
8 b# m& J3 ]" t+ y- u( d .default_trigger = "default-on",
% v" Y2 Z) e8 Z8 \; B },6 w) L4 v: j) k! v$ a
};
; ^* P, J# X. Q8 Z$ h
; \7 t% }4 G( h. n; B6 P5 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ t( U$ }( z! y .leds = da850_evm_tl_leds,
1 D1 [; [ F C" Q% ^6 T' I .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," h4 E) a+ r! @: J& b
};& C# V K* K% L0 k; T
+ Y, u" B" A. N) X) ]5 r( G
static void led_dev_release(struct device *dev): X0 m% g) ]' x' A p, \8 u
{! x, c+ c: [' u
};: ^0 m3 c, U$ T+ n* v) E
% k9 E j# ]- W2 i& X' q: D# a
static struct platform_device da850_evm_tl_leds_device = {- _. |2 d8 |) F+ y1 t
.name = "leds-gpio",
! J; h4 ]5 r; [ .id = 1,
6 ]0 B" j1 Z/ Y .dev = {
c1 D+ G! X e* l3 M" w' Q .platform_data = &da850_evm_tl_leds_pdata,
; `/ R( d- q2 D! Y/ d .release = led_dev_release," `( M, y* ~2 A/ s: y
}
( f0 g9 g6 o2 N( K};( U5 Q( `8 R2 \! b+ Y; y: c, \
# _! ?4 g* _& [0 j$ `- I( v7 q1 K7 \static int __init led_platform_init(void)0 v: k, P' @" z" ?* g
{
' T9 I. F) q& { int ret;
( F5 n! U/ G9 Y H' \" U9 |' k8 T#if 0
, H! Q/ z5 @) N8 U e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 F- s/ b/ u8 a4 ]" e. M7 s! Y- \6 u
if (ret)/ V1 z( d* s6 X# m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ R! w, ]7 S1 [; p4 \7 O "%d\n", ret);7 A+ X. f$ O! e- H
#endif
) o: v" f# `. C$ n# ^; ~ ret = platform_device_register(&da850_evm_tl_leds_device);/ P4 k7 n5 |1 y. |* ]4 }# p
if (ret)
: T0 f+ G" ]5 v- h/ x pr_warning("Could not register som GPIO expander LEDS");2 G8 _' Z2 {# C6 |3 t7 [
else8 ?: ?2 R- m c' t3 T# F3 d& {
printk(KERN_INFO "LED register sucessful!\n");7 }( X4 y8 y( G# R
4 x/ Q6 p8 D# g" l$ E2 k# g
return ret;
/ ~( e. i6 b8 r; w/ l9 o}
+ ~) a% t" I7 W v9 R3 w+ L) g% [* P7 M7 ` ]# W+ s+ u
static void __exit led_platform_exit(void)
# W5 E$ t& \, y2 N( j7 O{
0 d2 @ T$ }3 e# b( B# e platform_device_unregister(&da850_evm_tl_leds_device); S0 z" P7 }+ H- V ?
$ g5 K; R& F% H printk(KERN_INFO "LED unregister!\n");# F6 q; N- O/ }( B9 V3 H
}
4 z9 A- E C" V G5 Y& `" F+ }4 y) g' `( P2 k8 V, G
module_init(led_platform_init);6 \4 B$ e% Z- M3 x
module_exit(led_platform_exit);
. R F! q/ N4 a' r( m) |- w4 d A! _- m& S5 W. @( H e
MODULE_DESCRIPTION("Led platform driver");& t3 V1 a; }1 v! W+ {' w
MODULE_AUTHOR("Tronlong");
7 f9 u$ _! L: c3 o _MODULE_LICENSE("GPL");
7 C1 b( T% d% Y. K+ T
) p& F5 K5 ^* v8 i |
|